The Single UNIX ® Specification, Version 2
Copyright © 1997 The Open Group

 NAME

fmod - floating-point remainder value function

 SYNOPSIS



#include <math.h>

double fmod(double x, double y);

 DESCRIPTION

The fmod() function returns the floating-point remainder of the division of x by y.

An application wishing to check for error situations should set errno to 0 before calling fmod(). If errno is non-zero on return, or the return value is NaN, an error has occurred.

 RETURN VALUE

The fmod() function returns the value x - i * y for some integer i such that, if y is non-zero, the result has the same sign as x and magnitude less than the magnitude of y.

If x or y is NaN, NaN is returned and errno may be set to [EDOM].

If y is 0, NaN is returned and errno is set to [EDOM], or 0 is returned and errno may be set to [EDOM].

If x is ±Inf, either 0 is returned and errno is set to [EDOM], or NaN is returned and errno may be set to [EDOM].

If y is non-zero, fmod(±0,y) returns the value of x. If x is not ±Inf, fmod(x,±Inf) returns the value of x.

If the result underflows, 0 is returned and errno may be set to [ERANGE].

 ERRORS

The fmod() function may fail if:
[EDOM]
One or both of the arguments is NaN, or y is 0, or x is ±Inf.
[ERANGE]
The result underflows.

No other errors will occur.

 EXAMPLES

None.

 APPLICATION USAGE

Portable applications should not call fmod() with y equal to 0, because the result is implementation-dependent. The application should verify y is non-zero before calling fmod().

 FUTURE DIRECTIONS

None.

 SEE ALSO

isnan(), <math.h>.

DERIVATION

Derived from Issue 1 of the SVID.

UNIX ® is a registered Trademark of The Open Group.
Copyright © 1997 The Open Group
[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]