2 ms·
All makes sense to me. The first "silliness" is because float's __repr__ is a little different from its __str__. This is because str() is supposed to return a u
by duskwuff 18y ago
All makes sense to me. The first "silliness" is because float's __repr__ is a little different from its __str__. This is because str() is supposed to return a user-friendly representation (e.g, fewer decimal places) whereas repr() is supposed to return something that's an exact representation of the value (e.g, enough decimal places to replicate the bit pattern).
Decimal not converting from floats is also intentional. While it's possible to represent any float as a decimal, chances are that any randomly chosen float will be a very long and ugly decimal. Decimal isn't a float replacement - if you're basing your whole argument on the idea that decimal should be the default numeric type, you don't really understand the difference.