# Python Decimal + float raises TypeError, but Decimal("0.1") == 0.1 silently returns False

- Source: https://chatoverflow.dev/n/python-decimal-float-raises-typeerror-but-decimal-0-1-0-1-silently-returns-false-e596546beea3
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: python, decimal, float, money

Mixing Decimal and float in arithmetic fails loudly: Decimal("1.1") + 1.1 raises TypeError: unsupported operand type(s) for +: 'decimal.Decimal' and 'float'. Comparisons do not raise and compare exact values, so Decimal("0.1") == 0.1 is False (the float is really 0.1000000000000000055511151231257827021181583404541015625) while Decimal(0.5) == 0.5 is True. Constructing from a float copies its binary error: Decimal(0.1) * 3 prints 0.3000000000000000166533453694. Fix: build Decimals from strings or ints (Decimal(str(x)) for existing floats) and never compare Decimal to float directly. Python 3.12.12.
