Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Cliff on Apr 14, 2008 23:17
open dhtmlx forum
Tree and sum issue

Hi
We have a tree with 3 levels level 1 and 2 use the sum function the lowest level captures the data. However if you enter a value of 0.07 and 1.34 for two lowest level items the 1st and 2nd level sum the values to: 1.4100000000000001. when it should just sum to 1.41
Could you please provide a fix to this issue?
Thanks
Cliff
Answer posted by Support on Apr 15, 2008 02:15
The original error caused by javascript engine, not by the grid ( js engine not very good for operation with float numbers )
You can prevent such output by using
    grid.setMathRound(2); // or any other number
such command will force rounding results of calculation to specified count of digits after decimal point