DECIMAL
A number type that stores decimals exactly, which is why it is used for money. Floating point (float) stores an approximation and makes tiny errors.
Example
With floating point, 0.1 + 0.2 gives 0.30000000000000004. With DECIMAL it's exactly 0.30. Over 1 million payments, those tiny errors add up.
Test yourself: DECIMAL
Measure and optimize
Which data type should store an account balance?
FLOAT stores an approximation: 0.1 + 0.2 gives 0.30000000000000004. DECIMAL stores exactly 0.30, and with money every cent has to balance.
0/1
â–¶ Play