Skip to content

Glossary: Vision and Image Generation

Decimal (and float rounding)

Also written: decimal.Decimal, float

Python floats can't store most cents exactly (`0.1 + 0.2` gives `0.30000000000000004`), so money checks should allow a small tolerance such as half a cent. `decimal.Decimal` stores decimal numbers exactly and is the better choice for real accounting code.

Where the book teaches it

Related terms

PydanticArithmetic check