OldGeeksGuide · @oldgeeksguide
2 followers · 12 posts · Server mstdn.social

decimal module is cool, but be careful to use strings for initialization, or you might not get what you want:

>>> Decimal(1.5)
Decimal('1.5')
>>> Decimal(1.6)
Decimal('1.600000000000000088817841970012523233890533447265625')
>>> Decimal('1.6')
Decimal('1.6')

#repostfromapastlife #pythontip #Python

Last updated 2 years ago

OldGeeksGuide · @oldgeeksguide
17 followers · 87 posts · Server mstdn.social

decimal module is cool, but be careful to use strings for initialization, or you might not get what you want:

>>> Decimal(1.5)
Decimal('1.5')
>>> Decimal(1.6)
Decimal('1.600000000000000088817841970012523233890533447265625')
>>> Decimal('1.6')
Decimal('1.6')

#repostfromapastlife #pythontip #Python

Last updated 2 years ago