Data types for storing currency in web/desktop software development

MySQL is one of the most used database engine for web and desktop applications. In many software applications, storing currency is a must. For some other applications, the numbers need to store for scientific calculations. For currency, obviously we need 2 precision but for scientific calculations we may need more precisions. 

There are main two candidates for the above purposes. 

  1. FLOAT / DOUBLE
  2. DECIMAL

We need to know what are the basic differences between the above two. What is the best place to look at? MySql documentation.

FLOAT: "The FLOAT and DOUBLE types represent approximate numeric data values."

http://dev.mysql.com/doc/refman/5.0/en/floating-point-types.html

DECIMAL: "The DECIMAL and NUMERIC types store exact numeric data values."

http://dev.mysql.com/doc/refman/5.1/en/fixed-point-types.html

So, undoubtedly it is a must to use DECIMAL or NUMERIC for storing currency.

Designed and Developed by Coolbit Software Solutions