floor(3M) MATHEMATICAL LIBRARY floor(3M)
NAME
floor, floorf, ceil, ceilf, copysign, fmod, fmodf, fabs,
fabsf, rint, remainder - floor, ceiling, remainder, absolute
value functions
SYNOPSIS
cc [flag ...] file ... -lm [library ...]
#include <math.h>
double floor (double x);
float floorf (float x);
double ceil (double x);
float ceilf (float x);
double copysign (double x, double y);
double fmod (double x, double y);
float fmodf (float x, float y);
double fabs (double x);
float fabsf (float x);
double rint (double x);
double remainder (double x, double y);
DESCRIPTION
floor and floorf return the largest integer not greater than
x. ceil and ceilf return the smallest integer not less than
x.
copysign returns x but with the sign of y.
fmod and fmodf return the floating point remainder of the
division of x by y. More precisely, they return the number
f with the same sign as x, such that x = iy + f for some in-
teger i, and | f| <| y|.
fabs and fabsf return the absolute value of x, | x|.
rint returns the nearest integer value to its floating point
argument x as a double-precision floating point number. The
returned value is rounded according to the currently set
machine rounding mode. If round-to-nearest (the default
mode) is set and the difference between the function argu-
ment and the rounded result is exactly 0.5, then the result
Last change: Math Libraries 1
floor(3M) MATHEMATICAL LIBRARY floor(3M)
will be rounded to the nearest even integer.
remainder returns the floating point remainder of the divi-
sion of x by y. More precisely, it returns the value r = x
- yn, where n is the integer nearest the exact value x/y.
Whenever | n - x/y| = 1/2, then n is even.
SEE ALSO
abs(3C), matherr(3M).
DIAGNOSTICS
fmod and fmodf return x when y is 0 and set errno to EDOM.
remainder returns NaN when y is 0 and sets errno to EDOM.
In both cases, except in compilation modes -Xa or -Xc, a
message indicating DOMAIN error is printed on standard er-
ror. Except under -Xc, these error-handling procedures may
be changed with the function matherr.
Last change: Math Libraries 2