Mysql: money and floats

What do I need to store such amounts, such as: $ 1,200,000, $ 1,000 and $ 14.56? ($ dosn't count, it will be deleted)

+3
source share
2 answers

not to do. Store as int and multiply / divide by 100. For example. Store 14.56 as 1456, but / 100 when displayed. A floating point for storing currency simply requires rounding problems.

+4
source

Source: https://habr.com/ru/post/1735476/


All Articles