[issue42148] floating point representation issues

Eric V. Smith report at bugs.python.org
Sun Oct 25 13:28:49 EDT 2020


Eric V. Smith <eric at trueblade.com> added the comment:

This isn't a bug. It's due to the base 2 representation of floating point numbers. See for example: See https://docs.python.org/3/tutorial/floatingpoint.html

It's possible, depending on your use case, you might want to use the decimal module. But that has it's own issues that you should be aware of. For example, 1/7 is not exactly representable in either floats or Decimals.

----------
nosy: +eric.smith
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42148>
_______________________________________


More information about the Python-bugs-list mailing list