Message9159
Logged In: YES
user_id=31435
I reopened this, but unassigned it since I can't justify
working on it (the benefit/cost ratio of fixing it is down
in the noise compared to other things that should be done).
I no longer think we'd need a PEP to change the behavior,
and agree it would be nice to change it. Changing it may
surprise people expecting Python to work like C (C99 says
that when integral -> floating conversion is in range but
can't be done exactly, either of the closest representable
floating numbers may be returned; Python inherits the
platform C's behavior here for Python int -> Python float
conversion (C long -> C double); when the conversion is out
of range, C doesn't define what happens, and Python
inherits that too before 2.2 (Infinities and NaNs are what
I've seen most often, varying by platform); in 2.2 it
raises OverflowError).
I'm not sure it's possible for a<b and b<c and a==c, unless
the platform C is inconsistent (meaning that (double)i for
a fixed i returns the next-lowest double on some calls but
the next-higher on others). This brute-force searcher
didn't turn up any examples on my box:
f = 2L**53 - 5 # straddle the representable-as-double limit
nums = [f+i for i in range(50)]
nums.extend(map(float, nums))
for a in nums:
. for b in nums:
. if not a < b:
. continue
. for c in nums:
. if not b < c:
. continue
. if a >= c:
. print `a`, `b`, `c`
|
|
Date |
User |
Action |
Args |
2007-08-23 13:59:07 | admin | link | issue513866 messages |
2007-08-23 13:59:07 | admin | create | |
|