Next: , Previous: remainder, Up: Math


1.47 remquo, remquof–remainder and part of quotient

Synopsis

     #include <math.h>
     double remquo(double x, double y, int *quo);
     float remquof(float x, float y, int *quo);
     

Description
The remquo functions compute the same remainder as the remainder functions; this value is in the range -y/2 ... +y/2. In the object pointed to by quo they store a value whose sign is the sign of x/y and whose magnitude is congruent modulo 2**n to the magnitude of the integral quotient of x/y. (That is, quo is given the n lsbs of the quotient, not counting the sign.) This implementation uses n=31 if int is 32 bits or more, otherwise, n is 1 less than the width of int.

For example:

     	remquo(-29.0, 3.0, &quo)

returns -1.0 and sets quo=10, and

     	remquo(-98307.0, 3.0, &quo)

returns -0.0 and sets quo=-32769, although for 16-bit int, quo=-1. In the latter case, the actual quotient of -(32769=0x8001) is reduced to -1 because of the 15-bit limitation for the quotient.


Returns
When either argument is NaN, NaN is returned. If y is 0 or x is infinite (and neither is NaN), a domain error occurs (i.e. the "invalid" floating point exception is raised or errno is set to EDOM), and NaN is returned. Otherwise, the remquo functions return x REM y.


Bugs
IEEE754-2008 calls for remquo(subnormal, inf) to cause the "underflow" floating-point exception. This implementation does not.


Portability
C99, POSIX.