Alexander Belopolsky added the comment:

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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue22198>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to