Polybench® Reference
Parser for mathematical formulas

Mathematical formulas parser

Overview

Polybench contains a parser for mathematical formulas. This parser is used to do basic calculations on variables.

Polybench supports formulas in the following forms:
=a + b
=a - b
=a * b
=a / b

where a and b are either fixed values or variables containing numerical values. Multiple operators and parentheses can also be used.

Details

The Polybench formula parser works in relation to the SET_PARAMETER action ("SET_PARAMETER"). In the Value setting for the action a mathematical formula can be written.

A formula is only recognized if it starts with the equal-symbol: =.
Inside the formula you may use fixed numbers and/or variables (see "Variable Parameters").

For example, you have a global variable ("Free Global and Namespace Variables") called $var$ and it has the value 10.
You can now define an action (for example using an Action Button ("Action Button")) with following settings:
action: SET_PARAMETER
address: $var$
value: =2 * ($var$ + 1)

After the action has been executed, $var$ will be 22.

Real numbers vs. Natural numbers

If at least one of the values in the formula is a real number, then the result of the calculation will be displayed as a real number.
If all numbers are natural numbers (integers), then the result will be a natural number.

Result if a value is not a number

If one of the values in te formula is not a number, then of course nothing can be calculated. In that case, the formule is returned without the '=' sign.