# Evaluate numerical expressions in JSPWiki

Last edited: 18 Jul 2019

This JSPWiki plugin evaluates numerical expressions with or without parameters. The usage would be like this:

CodeSnippets

[{Evaluate expr='2*x + y - 42' x='16' y='13' showExpr='true' showVars='true'}]

And the result would be:

2*x + y - 42 = 3.0 (x=16.0, y=13.0)

If the `showExpr` parameter is missing or false, the result would just be

3.0

If the `showVars` parameter is missing or false, the result would be

2*x + y - 42 = 3.0

Parameters names can be 'a' through 'z'.

The source code is here. It needs the ExprJava class (where the expression syntax and the available functions are explained further). A jar file containing all my JSPWiki plugins is here.

CodeSnippets