Provided by: manpages-dev_5.05-1_all

**NAME**

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

**SYNOPSIS**

#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(): _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 500 || /* Since glibc 2.19: */ _DEFAULT_SOURCE || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCEremainderf(),remainderl(): _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L || /* Since glibc 2.19: */ _DEFAULT_SOURCE || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCEdrem(),dremf(),dreml(): /* Since glibc 2.19: */ _DEFAULT_SOURCE || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE

**DESCRIPTION**

These functions compute 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.

**RETURN** **VALUE**

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.

**ERRORS**

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 NaNerrnois set toEDOM(but see BUGS). 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.

**ATTRIBUTES**

For an explanation of the terms used in this section, seeattributes(7). ┌───────────────────────────┬───────────────┬─────────┐ │Interface│Attribute│Value│ ├───────────────────────────┼───────────────┼─────────┤ │drem(),dremf(),dreml(), │ Thread safety │ MT-Safe │ │remainder(),remainderf(), │ │ │ │remainderl() │ │ │ └───────────────────────────┴───────────────┴─────────┘

**CONFORMING** **TO**

The functionsremainder(),remainderf(), andremainderl() are specified in C99, POSIX.1-2001, and POSIX.1-2008. 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.

**BUGS**

Before glibc 2.15, the call remainder(nan(""), 0); returned a NaN, as expected, but wrongly caused a domain error. Since glibc 2.15, a silent NaN (i.e., no domain error) is returned. Before glibc 2.15,errnowas not set toEDOMfor the domain error that occurs whenxis an infinity andyis not a NaN.

**EXAMPLE**

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

**SEE** **ALSO**

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

**COLOPHON**

This page is part of release 5.05 of the Linuxman-pagesproject. A description of the project, information about reporting bugs, and the latest version of this page, can be found at https://www.kernel.org/doc/man-pages/. 2017-09-15 REMAINDER(3)