Variables have an internal value and a presentation value. The internal value is used for calculations within other variables. The presentation value is applied when the variable is used in other contexts, such as in text or rule definitions. Under the variable Preview label, the presentation value is displayed.
The internal value is the unrounded version based on the variable definition. The reason for this is to prevent variables from getting intermediate rounding errors.
Specifying the number of Decimals fields of the variable only affects the presentation value. If you want the definition of the variable to be truly rounded, you can use the
round(number, decimal places) function.
To demonstrate this, have a look at the following example where we use the decimal value of
$b are both defined as
1/7 and have a value of
11 in the Decimals field. However,
$b is defined as
1/7 rounded to
10 decimal places in the Definition as well. This leads to a small difference in the last decimal place between
$d we continue the calculation based on
$b, by multiplying them with
7 again. As you can see, the value of
$c is exactly 1, whereas the value of
$d is not.
This setup allows you to use decimal values outside of the variables scope (in texts or rule definitions), without introducing rounding errors within other variables.
Exception in double quoted variables
When a variable is used in another variable within double quotes, the presentation value is also used. See here a continued example:
Exception in inline text evaluation
When variables are used in inline evaluation in texts, so between
~ delimiters, the internal value will also be used, not the presentation values.