decimal module

Python's standard library module for exact decimal arithmetic, used where binary floats would round wrongly, such as money.

In more detail

A Decimal stores 1.178 exactly and lets you choose the rounding rule. Many systems instead keep money as whole numbers of the smallest unit, such as pence.

Related terms

Taught in

References