Databases

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?

Lessons that use it

More databases terms

All terms →

Arki, the beaver mascot

Your next interview starts with 5 minutes today.

Free on iOS and Android. Start from zero, no account needed.