Message134917
> The only way to do that now is t=frexp(x) and y=ldexp(t[0],t[1]+2).
What's wrong with the more direct ldexp(x, 2)?
N.B. There *are* edge cases where Martin's suggested alternative won't work. E.g., to compute 1e-300 * 2**1500:
>>> ldexp(1e-300, 1500)
3.507466211043404e+151
But:
>>> 1e-300 * (1 << 1500)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: long int too large to convert to float
I'm -1 on the proposal: I recognise the need for these operations, but I think 'ldexp(x, n)' gives an adequate solution. Fitting the functionality to the << and >> operators is awkward, because that's not what those operators do for integers (>> produces the *floor* of the quotient, and << doesn't currently accept negative arguments on the right, so there's no neat way for integers to divide by a power of 2).
See also the rejected issue 1205239. |
|
Date |
User |
Action |
Args |
2011-05-01 17:50:54 | mark.dickinson | set | recipients:
+ mark.dickinson, loewis, rhettinger, dtorp, eric.smith, daniel.urban |
2011-05-01 17:50:54 | mark.dickinson | set | messageid: <1304272254.43.0.149286889953.issue11967@psf.upfronthosting.co.za> |
2011-05-01 17:50:53 | mark.dickinson | link | issue11967 messages |
2011-05-01 17:50:53 | mark.dickinson | create | |
|