This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author steven.daprano
Recipients christian.heimes, mark.dickinson, rhettinger, scoder, steven.daprano, stutzbach, tim.peters
Date 2019-04-02.16:08:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1554221322.08.0.590345414062.issue36493@roundup.psfhosted.org>
In-reply-to
Content
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?
History
Date User Action Args
2019-04-02 16:08:42steven.dapranosetrecipients: + steven.daprano, tim.peters, rhettinger, mark.dickinson, scoder, christian.heimes, stutzbach
2019-04-02 16:08:42steven.dapranosetmessageid: <1554221322.08.0.590345414062.issue36493@roundup.psfhosted.org>
2019-04-02 16:08:42steven.dapranolinkissue36493 messages
2019-04-02 16:08:42steven.dapranocreate