money in cents
The practice of storing money as a whole number of the smallest unit, such as cents, so sums are exact.
In more detail
Integer arithmetic never rounds, so a basket total in cents is always right to the cent. Divide by one hundred only when displaying the value, and name the column for its unit, such as price_cents, so nobody mistakes it for pounds or dollars.
Example
(895 + 1250 + 2 * 340) / 100.0 AS displayRelated terms
- INTEGER — The column type for whole numbers, used in this course for keys, quantities and money stored in cents.
- floating-point number — A number with a fractional part stored in binary, which can only approximate most decimal values.
Taught in
- Data Types And What To Choose — PostgreSQL, Indexing & Relational Data Modeling
- Aggregate Functions — PostgreSQL, Indexing & Relational Data Modeling