fmod, _fmodl

Description

Calculate the floating-point remainder.

#include <math.h>

double fmod( doublex,doubley );

long double _fmodl( long doublex,long doubley );

x, y Floating-point values  

Remarks

The fmod and _fmodl functions calculate the floating-point remainder f of x / y such that x = i *y + f, where i is an integer, f has the same sign as x, and the absolute value of f is less than the absolute value of y.

The _fmodl function is the 80-bit counterpart; it uses the 80-bit, 10-byte coprocessor form of arguments and return values. See the discussion of the long double functions for more details on this data type.

Return Value

These functions return the floating-point remainder. If y is 0, the function returns 0.

Compatibility

fmod

Standards:ANSI, UNIX

16-Bit:DOS, QWIN, WIN, WIN DLL

32-Bit:DOS32X

_fmodl

Standards:None

16-Bit:DOS, QWIN, WIN, WIN DLL

32-Bit:None

See Also

ceil, fabs, floor

Example

/* FMOD.C: This program displays a floating-point remainder. */

#include <math.h>

#include <stdio.h>

void main( void )

{

double x = -10.0, y = 3.0, z;

z = fmod( x, y );

printf( "The remainder of %.2f / %.2f is %f\n", x, y, z );

}

Output

The remainder of -10.00 / 3.00 is -1.000000