HP-UX Reference (11i v2 07/12) - 3 Library Functions N-Z (vol 7)

t
trunc(3M) trunc(3M)
NAME
trunc(), truncf(), truncl(), truncw( ), truncq() - truncation functions
SYNOPSIS
#include <math.h>
double trunc(double x);
Itanium(R)-based System Only
float truncf(float x);
long double truncl(long double x);
extended truncw(extended x);
quad truncq(quad x);
DESCRIPTION
The trunc() function rounds its argument to the integral value, in floating-point format, nearest to but
no larger in magnitude than the argument.
Itanium-based System Only
truncf() is a float version of trunc(); it takes a float argument and returns a float
result.
truncl() is a long double version of trunc(); it takes a long double argument and returns
a
long double result.
truncw() is an extended version of trunc(); it takes an extended argument and returns an
extended result.
truncq() is equivalent to truncl() on HPUX systems.
USAGE
To use these functions, compile either with the default -Ae option or with the
-Aa and
-D_HPUX_SOURCE options.
To use (for Itanium-based systems)
truncw() or truncq(), compile also with the -fpwidetypes
option.
To use these functions, make sure your program includes
<math.h>. Link in the math library by specify-
ing -lm on the compiler or linker command line.
For more information, see the HP-UX Floating-Point Guide.
RETURN VALUE
If x is ±INFINITY or ±zero,
trunc() returns x.
If x is NaN, trunc() returns NaN.
trunc() may raise the inexact exception if x is non-integral and finite.
ERRORS
No errors are defined.
SEE ALSO
ceil(3M), floor(3M), fabs(3M), fmod(3M), fegetround(3M), fesetround(3M), lrint(3M), llrint(3M), lround(3M),
llround(3M), rint(3M), round(3M), math(5), fenv(5).
STANDARDS CONFORMANCE
trunc(), truncf() , truncl() : ISO/IEC C99 (including Annex F, ‘‘IEC 60559 floating-point arith-
metic’’)
HP-UX 11i Version 2: December 2007 Update 1 Hewlett-Packard Company 557