Problem/Motivation
When rounding is set to zero, it will not trigger. Also, if rounding is set to 2, and then calculation field sum used in some other total, because of number_format thousand separator is will break calculation.
If all fields are on the same page, everything works as expected.
Steps to reproduce
Page1, to hold num1 and num2 number fields. On Page2 add calc field (Sum1) with ":num1|0 + :num2|0" and rounding to 0 (zero). Add Page3 and Sum2 with ":sum1|0 + 1005" (or something).
Then view the webform, make sure to use numbers greater than 1000 for num1 and num2 with decimals.
If the rounding is set to zero, Sum1 will be unmodified
if (!empty($element["#evaluation_decimals"])) {
$result = number_format($result, $element["#evaluation_decimals"]);
}
Not empty will not trigger for "0" value, since that is a special case and is evaluated as false. But, if you change rounding to "2", then Sum1 will be formatted to include two decimal places and will use a thousand separators "," which then will break Sum2 on the next page.
Maybe using isset with is_numeric makes more sense.
Also, worth pointing out, if instead of number_format round command is used, then you can round to tens/hundreds/thousands; round(12345.678, -3) will result in 12000.