This content has been marked as final. Show 3 replies
That's a common problem when calculating with decimals, not only in Flash. There were some good explanations in this forum, but it seems I can't come up with the right search terms atm... In short, there are always some rounding operations when calculating with decimals, resulting in those strange results. You can try to search the forum, or read http://en.wikipedia.org/wiki/Floating_point, if you want to know more about it.
A way to avoid this is to convert the decimals into full numbers first, calculate, and then convert back to decimals. E.g., if you always have 2 decimal parts, multiply by 100 to get full numbers, do the calculation, then divide the result by 100 to move the decimal point back in place.
Forgot: when you take the numbers from a textfield, they come as a string, so you have to convert them to a number first before calculating with it. The parseFloat() function does this conversion.
That works great.
Tanx for your help!