Mathematical formulas parser
OverviewPolybench 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.
DetailsThe 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:
value: =2 * ($var$ + 1)
After the action has been executed, $var$ will be 22.
Real numbers vs. Natural numbersIf 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.