MySQL Forums
Forum List  »  General

Re: Floating Point and Platforms Question
Posted by: Bjørn Munch
Date: October 10, 2019 04:57AM

ANY platform will show this effect, it's unavoidable since it's an inherent property of floating point numbers. A number like 21.40 cannot be represented exactly in binary, just like a number like 5 1/3 cannot be represented exactly in decimal with fixed number of digits. But exactly which calculations give unexpected result may vary depending on the architecture.

As the page you referred to suggests, DECIMAL should avoid this as long as your numbers have a limited number of decimal digits. Or if you're dealing in money values, you can multiply by 100 and store the number of cents/pennies/whatever as integers internally.

Options: ReplyQuote

Written By
Re: Floating Point and Platforms Question
October 10, 2019 04:57AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.