floor(3M) 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 integer
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 argument and
the rounded result is exactly 0.5, then the result will be
rounded to the nearest even integer.
remainder returns the floating point remainder of the division
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.
Copyright 1994 Novell, Inc. Page 1
floor(3M) floor(3M)
Errors
When x is _ oo or y is zero fmod, fmodf and remainder return
IEEE NaN on systems that support it and raise the invalid
operation exception. Otherwise, they return 0. errno is set
to EDOM.
On systems that support IEEE NaN, if any of the inputs to each
of these functions is a quiet NaN, that value is returned. If
any of the inputs is a signaling NaN, a quiet NaN is returned
and the invalid operation exception is raised. In either
case, errno is set to EDOM.
If the program was compiled with the -Xt compilation mode,
fmod and fmodf return x when y is zero and set errno to EDOM.
In addition, a message indicating DOMAIN error is printed on
the standard error output. These error handling procedures
may be changed with the function matherr.
REFERENCES
abs(3C), cc(1), matherr(3M)
Copyright 1994 Novell, Inc. Page 2