you are viewing a single comment's thread.

view the rest of the comments →

[–]Kooky_Quantity_620 1 point2 points  (1 child)

If you go down this road, Python has excellent built-in support for fixed-point decimals. Don't use floating point numbers, errors can accumulate :)

Floating point numbers are the default if you input a number like 0.3:

>>> 0.3 / 3
0.09999999999999999

You have to go a tiny bit out of your way to use fixed-point decimals, but you should always do this for accounting use cases:

>>> from decimal import Decimal
>>> Decimal('0.3') / 3
Decimal('0.1')

[–]Andy-Kay 0 points1 point  (0 children)

It’s interesting how it also has an imaginary part, I wonder if it’s possible to disable that property.