When you create a MySQL data table, you often encounter storage decimals (floating point numbers), such as: Price, weight, height, etc.
There are three types of storage solutions prevalent in large companies:
1, the data to expand the multiples of 10 to use integer type storage purposes.
For example, the price, we often divided into units for storage, that is, to expand the data 100 times times, so that the meta-component storage.
Weight can be in grams, if grams or decimals, in MG, micrograms and other units for storage.
2. Store using the decimal type
such as the price, we can use two decimal places to store the precision. It is strongly not recommended to use float or double type storage, there will be a loss of precision, in the future when the value comparison, prone to incorrect results.
3, fractional and integer parts are stored separately.
For example, the price of 3.14, we saved into two fields, a field storage 3, a field storage 14, generally less use. When the stored data range is outside the range of decimal, you can split the data by integers and decimals.
The first option is recommended here.
Those things about MySQL (3) How decimals are stored