Within MySQL, most floating point numbers are represented in a compact, but inaccurate, format. If this sounds terrible, it isbut on the bright side, MySQL shares this problem with the rest of the computing world.
One partial exception to this behavior comes in the form of the DECIMAL-type column. DECIMAL columns store floating point numbers as strings, instead of as floating point numbers. This approach requires more space, but you can be sure of the level of precision in the data that you store in MySQL. Of course, there is a limit to how much data is in the DECIMAL column. The limit for the amount of data that can be stored has changed several times in recent versions of MySQL, so check the MySQL manual for more details. To be compatible with all released versions of MySQL, limit the number of digits to the right of the decimals to 30 or fewer.
DECIMAL is handled just like other column types. See Chapter 2, "Creating and Managing Databases, Tables, and Indexes," for more details.
If you do math on a DECIMAL-type column within MySQL, you face a loss in precision unless you are using MySQL version 5.0.3 or greater.