[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4.3 Base Operating System and Extensions Technical Reference, 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

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.

[ Previous | Next | Contents | Glossary | Home | Search ]