You have a friend in quantizeandROUND_FLOOR
>>> from decimal import Decimal,ROUND_FLOOR
>>> float(Decimal(str(2.667)).quantize(Decimal('.01'), rounding=ROUND_FLOOR))
2.66
>>> float(Decimal(str(-2.667)).quantize(Decimal('.01'), rounding=ROUND_FLOOR))
-2.67
Please note that you can use ROUND_DOWNfor positive numbers. As interjay mentions in the commentary , ROUND_DOWNrounds are zero and therefore may return incorrect values for negative numbers.
>>> from decimal import Decimal,ROUND_DOWN
>>> Decimal(str(2.667)).quantize(Decimal('.01'), rounding=ROUND_DOWN)
Decimal('2.66')
>>> float(Decimal(str(2.667)).quantize(Decimal('.01'), rounding=ROUND_DOWN))
2.66
source
share