Message75568
Mark,
I noticed that you replaced a call to _PyLong_AsScaledDouble with your
round to nearest algorithm. I wonder if _PyLong_AsScaledDouble itself
would benefit from your change. Currently it is used in PyLong_AsDouble
and long_true_divide. I would think that long_true_divide would be more
accurate if longs were rounded to the nearest float.
I also wonder whether round to nearest float can be implemented without
floating point arithmetics. I would think round towards zero should be
a simple matter of extracting an appropriate number of bits from the
long and round to nearest would at most require a long addition.
I believe _PyLong_AsScaledDouble is written the way it is to support
non-IEEE floating formats, but I am not sure that your algorithm would
always return the nearest float on an arbitrary non-IEEE platform.
Maybe it would be worthwhile to provide a simple IEEE specific code with
well specified semantics for both PyLong_AsDouble and long_true_divide,
but fall back to the current code on non-IEEE platforms. |
|
Date |
User |
Action |
Args |
2008-11-06 17:30:35 | belopolsky | set | recipients:
+ belopolsky, mark.dickinson, vstinner, drj |
2008-11-06 17:30:34 | belopolsky | set | messageid: <1225992634.77.0.711663565833.issue3166@psf.upfronthosting.co.za> |
2008-11-06 17:30:34 | belopolsky | link | issue3166 messages |
2008-11-06 17:30:32 | belopolsky | create | |
|