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;
The drem subroutine calculates 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.
cc drem.c -lm
x | Specifies double-precision floating-point value. |
y | Specifies a double-precision floating-point value. |
The drem subroutine returns a NaNQ value for (x, 0) and (+/-INF, y).
The floor, ceil, nearest, trunc, rint, itrunc, fmod, fabs, or uitruns (floor, floorf, floorl, nearest, trunc, itrunc, or uitrunc Subroutine) subroutine.
Subroutines Overview in AIX 5L Version 5.2 General Programming Concepts: Writing and Debugging Programs.