2 ms·
Sure, rounding is important as well. > I don't understand what you mean by "quirks in Python" Setting a precision for decimal numbers "globally" in the module
by raverbashing 11y ago
Sure, rounding is important as well.
> I don't understand what you mean by "quirks in Python"
Setting a precision for decimal numbers "globally" in the module. https://docs.python.org/2/library/decimal.html https://docs.python.org/2/library/decimal.html
But of course, working with cents might get complicated if you're doing a lot of calculations, people should use Decimal
Then there was Django's Decimal field which wouldn't even do comparisons correctly and was filled with bugs (in 1.2 at least)
- dalke 11y agoMinor correction; the decimal context is thread-local, and not set '"globally" in the module'. It's similar in philosophy to C99's support for IEEE 754's rounding modes and exception modes. Compare to http://en.cppreference.com/w/c/numeric/fenv http://en.cppreference.com/w/c/numeric/fenv : > The floating-point environment is the set of floating-point status flags and control modes supported by the implementation. It is thread-local, each thread inherits the initial state of its floating-point environment from the parent thread. Since standard floats in C have similar behavior, it's hard for me to agree that it's really a "quirk".