This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author belopolsky
Recipients belopolsky, drj, mark.dickinson, vstinner
Date 2008-11-06.17:30:32
SpamBayes Score 1.1805217e-08
Marked as misclassified No
Message-id <1225992634.77.0.711663565833.issue3166@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2008-11-06 17:30:35belopolskysetrecipients: + belopolsky, mark.dickinson, vstinner, drj
2008-11-06 17:30:34belopolskysetmessageid: <1225992634.77.0.711663565833.issue3166@psf.upfronthosting.co.za>
2008-11-06 17:30:34belopolskylinkissue3166 messages
2008-11-06 17:30:32belopolskycreate