Is the most significant decimal digits precision that can be converted to binary and back to decimal without loss of significance 6 or 7.225?

These are talking about two slightly different things. The 7.2251 digits is the precision with which a number can be stored internally. For one example, if you did a computation with a double precision number (so you were starting with something like 15 digits of precision), then rounded it to a single precision number, the … Read more

What is the purpose of max_digits10 and how is it different from digits10?

To put it simple, digits10 is the number of decimal digits guaranteed to survive text → float → text round-trip. max_digits10 is the number of decimal digits needed to guarantee correct float → text → float round-trip. There will be exceptions to both but these values give the minimum guarantee. Read the original proposal on … Read more

How to avoid floating point errors? [duplicate]

This really has nothing to do with Python – you’d see the same behavior in any language using your hardware’s binary floating-point arithmetic. First read the docs. After you read that, you’ll better understand that you’re not adding one one-hundredth in your code. This is exactly what you’re adding: >>> from decimal import Decimal >>> … Read more