Aloha,
I have a stack doing some math on floating point numbers. Because
they are supposed to be dollar figures, I have to show only 2 decimal
places. I have to mutiply by percentages and round (example, 50%
discount on $0.65 = $0.33).
Problem: after calculating a result like the above, I add it to 3
different globals - a column total, a line total, and a cumulative
total. If there is only one column, all three numbers should be the
same but eventually, they start getting out of sync with each other, a
penny or two off.
Why does this happen? Do I need to initialize these variables
in a certain way or do the math in a certain way to work around the
problems? Anyone with experience, please help!
Here is a section of code representing some math,
put factor * rate * number_of_performers into temp_category_total
put (round(100 * temp_category_total) / 100) into category_total
put cumulative_total + category_total into cumulative_total
put line_total + category_total into line_total
return category_total
Any ideas?
Mahalo!
Sadhu
Archives: http://www.mail-archive.com/[email protected]/
Info: http://www.xworlds.com/metacard/mailinglist.htm
Please send bug reports to <[EMAIL PROTECTED]>, not this list.