floating-point remainder function

You're viewing an older version of this page (#3326). View the current version.

View versions (4)

NAME

fmod

INTERFACE

#include <math.h>

double fmod ( double x, double y ) long fmodl ( long double x, long double y ) float fmodf ( float x, float y )

DESCRIPTION

The fmod functions compute the floating-point remainder of x/ y.

Specifically, the functions return the value x -i\a * 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.

Example 1

#include <math.h>
#include <stdio.h>

int main(void)
{
  printf("fmod of 10.0, 3.0 is %1.1f", fmod(10.0, 3.0));
  return 0;
}

output

fmod of 10.0, 3.0 is 1.0

SPECIAL VALUES

fmod ( 0, y ) returns 0 for y not zero.

fmod ( x, y ) returns a NaN and raises the invalid floating-point exception for x &infin; or y zero.

fmod ( x, &infin;) returns x for x not &infin;.

STANDARDS

The fmod functions conform to ISO/IEC 9899:1999(E).