Message9161
Logged In: YES
user_id=72053
I hope there's a simple solution to this--it's obvious what
the right result should be mathematically if you compare
1L<<10000 with 0.0. It should not raise an error. If the
documented behavior leads to raising an error, then there's
a bug in the document. I agree that it's not the highest
priority bug in the world, but it doesn't seem that complicated.
If n is a long and x is a float, both >= 0, what happens if
you do this, to implement cmp(n,x):
xl = long(x)
# if x has a fraction part and int part is == n, then x>n
if float(xl)!=x and xl==n: return 1
return cmp(n, xl)
If both are < 0, change 1 to -1 above. If x and n are of
opposite sign, the positive one is greater.
Unless I missed something (which is possible--I'm not too
alert right now) the above should be ok in all cases.
Basically you use long as the common type to convert to; you
do lose information when converting a non-integer, but for
the comparison with an integer, you don't need the lost
information other than knowing whether it was nonzero, which
you find out by converting the long back to a float. |
|
Date |
User |
Action |
Args |
2007-08-23 13:59:07 | admin | link | issue513866 messages |
2007-08-23 13:59:07 | admin | create | |
|