floor(3M) DG/UX R4.11MU05 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| = ½,
then n is even.
Those functions using float arguments, floorf, ceilf, fmodf, and fab
sf will give unpredictable results when used with the -Xt compilation
option. In traditional compilation mode float arguments are promoted
to doubles. An object compiled with -Xt will expect this promotion
and therefore not work correctly with these functions.
Considerations for Threads Programming
+----------+-----------------------------+
| | async- |
|function | reentrant cancel cancel |
| | point safe |
+----------+-----------------------------+
|ceil | Y N N |
|ceilf | Y N N |
|copysign | Y N N |
|fabs | Y N N |
|fabsf | Y N N |
|floor | Y N N |
|floorf | Y N N |
|fmod | Y N N |
|fmodf | Y N N |
|remainder | Y N N |
|rint | Y N N |
+----------+-----------------------------+
DIAGNOSTICS
When the -Xt compilation option is used, 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, a message indicating DOMAIN error
is printed on standard error.
When the -Xa or -Xc compilation options are used, fmod, fmodf and re
mainder return IEEE NaN, raise an invalid operation exception, and
set errno to EDOM when x is "+-inf" or y is zero.
For each of these functions, if any argument is a quiet NaN, that
value is returned. If any argument is a signaling NaN, a quiet NaN
is returned and an invalid operation exception is raised. In either
case, errno is set to EDOM, and a message indicating DOMAIN error is
printed on the standard error output.
When the -Xt compilation option is used, these error-handling proce
dures may be changed with the function matherr.
When the -Xa or -Xc compilation options are used, no error messages
are printed.
SEE ALSO
cc(1), reentrant(3), abs(3C), matherr(3M), fpsetmask(3C).
Licensed material--property of copyright holder(s)