drem, dremf, dreml, remainder, remainderf, remainderl - floating-point remainder function

Synopsis

Description

Errors

Bugs

Example

Colophon

Link with#include <math.h>/* The C99 versions */

double remainder(doublex, doubley);float remainderf(floatx, floaty);long double remainderl(long doublex, long doubley);/* Obsolete synonyms */

double drem(doublex, doubley);float dremf(floatx, floaty);long double dreml(long doublex, long doubley);

-lm.Feature Test Macro Requirements for glibc (see

feature_test_macros(7)):

remainder():_SVID_SOURCE || _BSD_SOURCE || _XOPEN_SOURCE >= 500 || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED || _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L;

orcc -std=c99

remainderf(),remainderl():_BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 600 || _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L;

orcc -std=c99

drem(),dremf(),dreml():_SVID_SOURCE || _BSD_SOURCE

Theremainder() function computes the remainder of dividingxbyy. The return value isx-n*y, wherenis the valuex / y, rounded to the nearest integer. If the absolute value ofx-n*yis 0.5,nis chosen to be even.These functions are unaffected by the current rounding mode (see

fenv(3)).The

drem() function does precisely the same thing.

On success, these functions return the floating-point remainder,x-n*y. If the return value is 0, it has the sign ofx.If

xoryis a NaN, a NaN is returned.If

xis an infinity, andyis not a NaN, a domain error occurs, and a NaN is returned.If

yis zero, andxis not a NaN, a domain error occurs, and a NaN is returned.

Seemath_error(7) for information on how to determine whether an error has occurred when calling these functions.The following errors can occur:

Domain error: xis an infinity andyis not a NaNAn invalid floating-point exception ( FE_INVALID) is raised.These functions do not set errnofor this case.Domain error: yis zeroerrnois set toEDOM. An invalid floating-point exception (FE_INVALID) is raised.

The functionsremainder(),remainderf(), andremainderl() are specified in C99 and POSIX.1-2001.The function

drem() is from 4.3BSD. Thefloatandlong doublevariantsdremf() anddreml() exist on some systems, such as Tru64 and glibc2. Avoid the use of these functions in favor ofremainder() etc.

The callremainder(nan(""), 0);

returns a NaN, as expected, but wrongly causes a domain error; it should yield a silent NaN.

The call "remainder(29.0, 3.0)" returns -1.

div(3),fmod(3),remquo(3)

This page is part of release 3.44 of the Linuxman-pagesproject. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/.

REMAINDER (3) | 2010-09-20 |