I don’t know why, I don’t know the details of the modular implementation for float, however this works fine:
from decimal import Decimal
Decimal("59.28") % Decimal("3.12")
EDIT: Note that quotes "(i.e. strings) must be used in constructors . Otherwise, he will try to interpret both numbers as floats, which are the source of the problem (incorrect approximation).
source
share