[issue32783] ln(2) isn't accurate in _math.c in cpython

2018-02-07 Thread Mark Dickinson
Mark Dickinson added the comment: Closing. There's no actual bug here. -- resolution: -> not a bug stage: needs patch -> resolved status: open -> closed ___ Python tracker

[issue32783] ln(2) isn't accurate in _math.c in cpython

2018-02-07 Thread Mark Dickinson
Mark Dickinson added the comment: > I'm inclined to just close this as "not a bug". Sounds good to me. The ideal would probably be to use a hex literal here. They're part of C99 (see section 6.4.4.2), but last time I checked Visual Studio didn't support them. I don't

[issue32783] ln(2) isn't accurate in _math.c in cpython

2018-02-06 Thread Tim Peters
Tim Peters added the comment: As I mentioned on StackOverflow, the literal in question appears to have been crafted to convert to the best possible 53-bit binary approximation to log(2) regardless of whether a compiler converts it to double precision (53 bits of precision)

[issue32783] ln(2) isn't accurate in _math.c in cpython

2018-02-06 Thread Steven D'Aprano
Steven D'Aprano added the comment: Thanks for the link to the Stackoverflow discussion. Currently there are three answers: two (correctly) answer that the constant as given is the most accurate value for IEEE-754 floats. Tim Peters has answered that:

[issue32783] ln(2) isn't accurate in _math.c in cpython

2018-02-06 Thread Christian Heimes
Christian Heimes added the comment: Welcome to the astounding world of IEEE 754 floating point operations. Python's float type is based on C's 64bit double precision float. The value in _math.c is as precise as a double is able to contain: >>>

[issue32783] ln(2) isn't accurate in _math.c in cpython

2018-02-06 Thread R. David Murray
Change by R. David Murray : -- nosy: +mark.dickinson ___ Python tracker ___ ___

[issue32783] ln(2) isn't accurate in _math.c in cpython

2018-02-06 Thread Matanya Stroh
New submission from Matanya Stroh : In cpython/Modules/_math.c there is definition of as const ln2 the value that in that const isn't correct (at least not accurate) This is value that in the file: ln2 = 0.693147180559945286227 (cpython) but when calculating the value