[New-bugs-announce] [issue9959] int(math.log(4, 2)) == 1 instead of 2

akira report at bugs.python.org
Mon Sep 27 15:23:04 CEST 2010


New submission from akira <4kir4.1i at gmail.com>:

$ python3.1 -c'import math; f = math.log(4,2); print(int(f), f.as_integer_ratio())'
2 (2, 1)

$ python3.2 -c'import math; f = math.log(4,2); print(int(f), f.as_integer_ratio())'
1 (9007199254740991, 4503599627370496)

Python 3.2a2+ (py3k:85028, Sep 27 2010, 16:46:11) 
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import math
>>> f = math.log(32, 2)
>>> f
4.999999999999999
>>> int(f)
4
>>> f.as_integer_ratio()
(5629499534213119, 1125899906842624)

I'm not sure whether it is a bug, but it is an unexpected change in behavior between 3.1 and 3.2.

----------
components: Library (Lib)
messages: 117444
nosy: akira
priority: normal
severity: normal
status: open
title: int(math.log(4,2)) == 1 instead of 2
type: behavior
versions: Python 3.2

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9959>
_______________________________________


More information about the New-bugs-announce mailing list