[Python-Dev] Floating point test_pow failure on the alpha Debian buildbot

Tim Peters tim.peters at gmail.com
Thu Jul 26 17:34:02 CEST 2007


[Nick Coghlan]
> test_pow is failing on the alpha Debian buildbot, complaining that a
> negative number can't be raised to a fractional power. Now, to work
> around some bugs in platform implementations of math.fpow(), pow() does
> its own check to see if the exponent is an integer.
>
> The way pow() does that check is to try "iw == floor(iw)", so to see why
> the exception was being triggered, I put a couple of extra output lines
> into the test and got:
>
> *** Number: 1.2299999999999999e+167
> *** Floor: 1.2299999999999997e+167
>
> Given that the magnitude of the exponent significantly exceeds the
> precision of an IEEE double, it seems wrong for floor() to be changing
> the mantissa like that

It is wrong -- the machine representation of test_pow's 1.23e167
literal is an exact integer on any current box, and the floor of any
exact integer is the integer itself.

> (and, on my machine, and all of the other buildbots, it doesn't).
>
> I've added an explicit test for this misbehaviour to test_math so at
> least the buildbot gives a clearer indication of what's going wrong, but
> I'm not sure what to do with it beyond that.

This isn't Python's problem -- a bug report should be opened against
the platform C's implementation of floor(), and the test /should/ fail
in Python so long as the platform floor() remains broken.


More information about the Python-Dev mailing list