Message339349
I see this has been rejected for the math module, but I wonder whether it should be considered for Decimal? I recall Mark Dickinson demonstrating this lovely little bit of behaviour:
py> from decimal import getcontext, Decimal
py> getcontext().prec = 3
py> x = Decimal('0.516')
py> y = Decimal('0.518')
py> (x + y) / 2
Decimal('0.515')
To prove its not a fluke, or an artifact of tiny numbers:
py> getcontext().prec = 28
py> a = Decimal('0.10000000000000000009267827205')
py> b = Decimal('0.10000000000000000009267827207')
py> a <= (a + b)/2 <= b
False
py> a = Decimal('710000000000000000009267827205')
py> b = Decimal('710000000000000000009267827207')
py> a <= (a + b)/2 <= b
False
Thoughts? |
|
Date |
User |
Action |
Args |
2019-04-02 16:08:42 | steven.daprano | set | recipients:
+ steven.daprano, tim.peters, rhettinger, mark.dickinson, scoder, christian.heimes, stutzbach |
2019-04-02 16:08:42 | steven.daprano | set | messageid: <1554221322.08.0.590345414062.issue36493@roundup.psfhosted.org> |
2019-04-02 16:08:42 | steven.daprano | link | issue36493 messages |
2019-04-02 16:08:42 | steven.daprano | create | |
|