Hi guys,
I'm developing a data form with nested repeating groups. I have all of the data coming across perfectly and it's a beautiful thing! The problem i am discovering in our form(s) is that when we calculate a new budget, simple addition, we get a long decimal value. Not a big problem, or so i thought. I attempted a round function. It will work for a few fields of data but not all and then others that were once fine in double decimal were now calculating a long decimal value. So i attempted another fix by converting it into a string then taking out only the numbers before the decimal and only 2 after. The problem with this is that without the rounding we loose pennies with each new calculation of budget. I have done research and found that there is an issue with the floating arithemetic for calc values in xpath. Have any of you encountered this problem before? Is there a quick and easy fix? Any help is welcome.
number(substring(string(o_labour + o_expense), 1, string-length(substring-before(string(o_labour + o_expense), ".")) + 3)) --- to convert to string and truncate decimal (ex: 2.34566 to 2.34)
round(number(substring(string(o_labour + o_expense), 1, string-length(substring-before(string(o_labour + o_expense), ".")) + 3)) * 100) * .01 -- rounding function
I've applied both methods boht with and without the string number convert and with and without rounding functions at all field levels. I know for a fact that the data is not the cause of the problem. I have screenshots i can provide in email.
Michael