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, eryksun, mark.dickinson, petr.viktorin, rhettinger, skrah, steven.daprano, tim.peters
Date 2014-09-22.20:44:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1411418653.59.0.619563571239.issue22198@psf.upfronthosting.co.za>
In-reply-to
Content
I wonder if it would make sense to rewrite float_divmod using the newer POSIX/C99 remquo function.  I believe it is designed to compute the exact value of round(x/y), but getting floor instead should not be hard.  Its behavior on special values is fully specified. 



From the Linux man-page (I believe POSIX/C99 only guarantees 3 bits in quo):

NAME
     remquo -- floating-point remainder and quotient function

SYNOPSIS
     #include <math.h>

     double
     remquo(double x, double y, int *quo);

     long double
     remquol(long double x, long double y, int *quo);

     float
     remquof(float x, float y, int *quo);

DESCRIPTION
     The remquo() functions compute the value r such that r = x - n*y, where n is
     the integer nearest the exact value of x/y.

     If there are two integers closest to x/y, n shall be the even one. If r is
     zero, it is given the same sign as x.  This is the same value that is
     returned by the remainder() function.  remquo() also calculates the lower
     seven bits of the integral quotient x/y, and gives that value the same sign
     as x/y. It stores this signed value in the object pointed to by quo.

SPECIAL VALUES
     remquo(x, y, quo) returns a NaN and raises the "invalid" floating-point
     exception if x is infinite or y is 0.
History
Date User Action Args
2014-09-22 20:44:13belopolskysetrecipients: + belopolsky, tim.peters, rhettinger, mark.dickinson, steven.daprano, petr.viktorin, skrah, eryksun
2014-09-22 20:44:13belopolskysetmessageid: <1411418653.59.0.619563571239.issue22198@psf.upfronthosting.co.za>
2014-09-22 20:44:13belopolskylinkissue22198 messages
2014-09-22 20:44:13belopolskycreate