Computes the IEEE Remainder as defined in the IEEE Floating-Point Standard.
IEEE Math Library (libm.a)
or System V Math Library (libmsaa.a)
#include <math.h>
double drem (x, y) double x, y;
double remainder (double x, double y);
The drem or remainder subroutines calculate the remainder r equal to x minus n to the x power multiplied by y (r = x - n * y), where the n parameter is the integer nearest the exact value of x divided by y (x/y). If |n -x/y| = 1/2, then the n parameter is an even value. Therefore, the remainder is computed exactly, and the absolute value of r (|r|) is less than or equal to the absolute value of y divided by 2 (|y|/2).
The IEEE Remainder differs from the fmod subroutine in that the IEEE Remainder always returns an r parameter such that |r| is less than or equal to |y|/2, while FMOD returns an r such that |r| is less than or equal to |y|. The IEEE Remainder is useful for argument reduction for transcendental functions.
Note: Compile any routine that uses subroutines from the libm.a library with the -lm flag. For example: compile the drem.c file:cc drem.c -lm
x | Specifies double-precision floating-point value. |
y | Specifies a double-precision floating-point value. |
The drem or remainder subroutines return a NaNQ value for (x, 0) and (+/-INF, y).
The remainder subroutine returns a NaNQ value for ( x, 0.0 ) [ x not equal to NaN ] and (+/-INF, y ) [ y not equal to NaN ] and set errno to EDOM.
This subroutine is part of Base Operating System (BOS) Runtime.
Note: For new development, the remainder subroutine is the preferred interface.
The copysign, nextafter, scalb, logb, or ilog subroutine, floor, ceil, nearest, trunc, rint, itrunc, fmod, fabs, or uitruns subroutine.
IEEE Standard for Binary Floating-Point Arithmetic (ANSI/IEEE Standards 754-1985 and 854-1987) describes the IEEE Remainder Function.
Subroutines Overview in AIX General Programming Concepts: Writing and Debugging Programs.