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

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

## drem or remainder 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;

```double remainder (double x, double y);
```

### Description

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
```

### Parameters

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

### Return Values

The drem or remainder subroutines return a NaNQ value for (x, 0) and (+/-INF, y).

### Error Codes

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.

### Implementation Specifics

This subroutine is part of Base Operating System (BOS) Runtime.

Note: For new development, the remainder subroutine is the preferred interface.

### Related Information

The copysign, nextafter, scalb, logb, or ilog (copysign, nextafter, scalb, logb, or ilogb Subroutine) subroutine, floor, ceil, nearest, trunc, rint, itrunc, fmod, fabs, or uitruns (floor, floorl, ceil, ceill, nearest, trunc, rint, itrunc, uitrunc, fmod, fmodl, fabs, or fabsl Subroutine) subroutine.

Subroutines Overview in AIX 5L Version 5.1 General Programming Concepts: Writing and Debugging Programs.

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