Man Linux: Main Page and Category List

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

#include<math.h>/* The C99 versions */doubleremainder(doublex,doubley);floatremainderf(floatx,floaty);longdoubleremainderl(longdoublex,longdoubley);/* Obsolete synonyms */doubledrem(doublex,doubley);floatdremf(floatx,floaty);longdoubledreml(longdoublex,longdoubley);Link with-lm. Feature Test Macro Requirements for glibc (seefeature_test_macros(7)):remainder(): _SVID_SOURCE || _BSD_SOURCE || _XOPEN_SOURCE >= 500 || _ISOC99_SOURCE; orcc-std=c99remainderf(),remainderl(): _SVID_SOURCE || _BSD_SOURCE || _XOPEN_SOURCE >= 600 || _ISOC99_SOURCE; orcc-std=c99drem(),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 (seefenv(3)). Thedrem() 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. Ifxoryis a NaN, a NaN is returned. Ifxis an infinity, andyis not a NaN, a domain error occurs, and a NaN is returned. Ifyis 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 NaN An invalid floating-point exception (FE_INVALID) is raised. These functions do not seterrnofor 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 functiondrem() is from 4.3BSD. Thefloatandlongdoublevariantsdremf() anddreml() exist on some systems, such as Tru64 and glibc2. Avoid the use of these functions in favor ofremainder() etc.

The call remainder(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.24 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/. 2009-02-04 REMAINDER(3)