floor(3M)
NAME
floor, ceil, fmod, fabs, rint, fabsf, fmodf − floor, ceiling, remainder, absolute value, and round-to-nearest functions
SYNOPSIS
#include <math.h>
double floor(double x);
double ceil(double x);
double fmod(double x, double y);
double fabs(double x);
double rint(double x);
float fabsf(float x);
float fmodf(float x, float y);
DESCRIPTION
floor() returns the largest integer (as a double-precision number) not greater than x.
ceil() returns the smallest integer not less than x.
fmod() returns the floating-point remainder (f) of the division of x by y, where f has the same sign as x, such that x=iy+f for some integer i, and |f| < |y|.
fabs() returns the absolute value of x, |x|.
rint() returns the integer (represented as a double precision number) nearest x in the direction of the prevailing rounding mode.
fabsf() and fmodf() are float versions of fabs() and fmod(); they take float arguments and return float results. Their performance is significantly faster than that of the double versions. Programs must be compiled in ANSI mode (with the -Aa option) in order to use these functions; otherwise, the compiler promotes the float arguments to double, and the functions return incorrect results.
DEPENDENCIES
Series 300/400
fabsf(), fmodf(), and rint() are not supported on Series 300/400 systems.
Series 700/800
fabsf(), fmodf(), and rint() are not specified by any standard (fabsf() and fmodf() are, however, named in accordance with the conventions specified in the "Future Library Directions" section of the ANSI C standard). These functions are provided in the PA1.1 versions of the math library only. The +DA1.1 linker option (default on Series 700 systems) links in a PA1.1 version automatically. A PA1.1 library can also be linked in explicitly. For more information, see the HP-UX Floating-Point Guide.
/lib/libm.a
When x is ±INFINITY, floor(), ceil(), and rint() return ±INFINITY respectively.
fabs() returns +INFINITY when x is ±INFINITY.
fmod() returns x if y is 0.0, if x/y would overflow, or if x/y would underflow (including when y is ±INFINITY).
/lib/libM.a
No error messages are printed on the standard error output.
When x is ±INFINITY, floor(), ceil(), and rint() return ±INFINITY respectively.
fabs() returns +INFINITY when x is ±INFINITY.
fmod() returns 0.0 if x/y would overflow, or x if x/y would underflow (including when y is ±INFINITY).
NOTES
In the default rounding mode (round to nearest), on a machine that conforms to the IEEE -754 standard, rint(x) is the integer nearest x with the additional stipulation that if | rint(x) −x|=1/2, then rint(x) is even. Other rounding modes can make rint() act like floor(), or like ceil(), or round toward 0.
Another way to obtain an integer near x is to declare (in C):
double x; int k; k = x;
The HP C compiler rounds x toward 0 to get the integer k. Note that if x is larger than k can accommodate, the value of k and the presence or absence of an integer overflow are hard to predict.
ERRORS
/lib/libm.a
floor() and ceil() return NaN and set errno to EDOM when x is NaN.
fmod() returns NaN and sets errno to EDOM when x or y is NaN, or when x is ±INFINITY.
fabs() returns NaN and sets errno to EDOM when x is NaN.
/lib/libM.a
floor() and ceil() return NaN and set errno to EDOM when x is NaN.
fmod() returns NaN and sets errno to EDOM when y is 0.0, when x or y is NaN, or when x is ±INFINITY.
fabs() returns NaN and sets errno to EDOM when x is NaN.
SEE ALSO
abs(3C), isinf(3M), isnan(3M), ieee(3M).
STANDARDS CONFORMANCE
floor() in libm.a: AES, SVID2, XPG2, XPG3, FIPS 151-2, POSIX.1
floor() in libM.a: AES, XPG3, XPG4, FIPS 151-2, POSIX.1, ANSI C
ceil() in libm.a: AES, SVID2, XPG2, XPG3, FIPS 151-2, POSIX.1
ceil() in libM.a: AES, XPG3, XPG4, FIPS 151-2, POSIX.1, ANSI C
fabs() in libm.a: AES, SVID2, XPG2, XPG3, FIPS 151-2, POSIX.1
fabs() in libM.a: AES, XPG3, XPG4, FIPS 151-2, POSIX.1, ANSI C
fmod() in libm.a: AES, SVID2, XPG2, XPG3, FIPS 151-2, POSIX.1
fmod() in libM.a: AES, XPG3, XPG4, FIPS 151-2, POSIX.1, ANSI C
Hewlett-Packard Company — HP-UX Release 9.0: August 1992