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 vstinner
Recipients jcea, mark.dickinson, python-dev, rhettinger, vstinner
Date 2011-05-09.12:50:42
SpamBayes Score 0.0052150115
Marked as misclassified No
Message-id <1304945447.81.0.388594193202.issue11888@psf.upfronthosting.co.za>
In-reply-to
Content
> we should check that it's not pow that's at fault here

Some tests on Mac OS X Tiger:

>>> (2.0 ** -255).hex()
'0x1.0000000000000p-255'

=> pow is correct

>>> import ctypes; import ctypes.util, math
>>> libc = ctypes.cdll.LoadLibrary(ctypes.util.find_library('c'))
>>> clog2=libc.log2
>>> clog2.restype=ctypes.c_double
>>> clog2.argtypes=(ctypes.c_double,)
>>> clog2(2.0**-255)
-254.99999999999997
>>> math.log(2.0**-255) / math.log(2.0)
-255.0

>>> math.log(2.0**-255)
-176.75253104278605
>>> math.log(2.0**-255).hex()
'-0x1.61814bbfb3fb5p+7'
>>> math.log(2.0)
0.6931471805599453
>>> math.log(2.0).hex()
'0x1.62e42fefa39efp-1'

>>> clog2(2.0**-255).hex()
'-0x1.fdfffffffffffp+7'
>>> (math.log(2.0**-255) / math.log(2.0)).hex()
'-0x1.fe00000000000p+7'

clog2() is wrong for 2^-255.
History
Date User Action Args
2011-05-09 12:50:47vstinnersetrecipients: + vstinner, rhettinger, jcea, mark.dickinson, python-dev
2011-05-09 12:50:47vstinnersetmessageid: <1304945447.81.0.388594193202.issue11888@psf.upfronthosting.co.za>
2011-05-09 12:50:42vstinnerlinkissue11888 messages
2011-05-09 12:50:42vstinnercreate