← TechnologyThe essentials of

Decimal: why the starting value matters

Publisher: ResumeMaker • 1 source

Published: 22 Oct 2026 16:11 · Updated: 22 Oct 2026 16:11

AI source check: 22 Oct 2026 14:04. This is not editorial approval.

In a few sentences

In brief

Decimal can represent decimal values that binary float cannot represent exactly. After from decimal import Decimal, Decimal('0.1') + Decimal('0.2') produces Decimal('0.3').

Useful to know

Decimal can represent decimal values that binary float cannot represent exactly. After from decimal import Decimal, Decimal('0.1') + Decimal('0.2') produces Decimal('0.3'). [1]

Constructing it from an already inexact float does not recover the original intention. Use suitable input and an explicit rounding rule for amounts. Choosing a numeric type does not itself define an invoice’s business rules.

Sources

For further detail and to check the information:

  1. [1] decimal — Decimal fixed-point and floating-point arithmetic — Python 3.12.15 documentation ↗