[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

# Technical Reference: Base Operating System and Extensions, Volume 1

## drem Subroutine

### Purpose

Computes the IEEE Remainder as defined in the IEEE Floating-Point Standard.

### Libraries

IEEE Math Library (libm.a)
or System V Math Library (libmsaa.a)

### Syntax

`#include <math.h>`

double drem ( x, y)
double x, y;

### Description

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.

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`
Note
For new development, the remainder subroutine is the preferred interface.

### Parameters

 x Specifies double-precision floating-point value. y Specifies a double-precision floating-point value.

### Return Values

The drem subroutine returns a NaNQ value for (x, 0) and (+/-INF, y).

### Related Information

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.

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]