Skip to catalogue

265

minor units

also cents, money integer, decimal scale

Money is an integer of the smallest unit, plus a currency. It is not a float.

What is minor units?

A minor unit is the smallest currency division: cents for USD, yen has zero decimal places. Store an integer count of those units and an ISO currency code. Binary floats cannot represent 0.10. A decimal type is acceptable when the scale is fixed and you do not mix it with float math.

Why does minor units matter when vibe coding?

The draft uses float64 or a JavaScript number for a price. 0.1 plus 0.2 is not 0.3. A sum of line items is a cent off, and the payout job “fixes” it by rounding at the end.

How do you do minor units?

Integer minor units in storage and APIs. Format for humans at the edge. Do not add values of different currencies. Do not round a float back into cents.

How do you ask a model for minor units?

Store (price) as integer minor units and an ISO currency code. Do not use float or a JavaScript number. Do not add two currencies. Format the decimal only in the response.

What goes wrong with minor units?

Multiplying a minor-unit integer by a float tax rate. The tax is a float again. Compute the rate in integer arithmetic or a fixed-scale decimal.

adjacent