fesetprec(3M) Mathematical Library Functions fesetprec(3M)NAME
fesetprec, fegetprec - control floating point rounding precision modes
SYNOPSIS
cc [ flag... ] file... -lm [ library... ]
#include <fenv.h>
int fesetprec(int prec);
int fegetprec(void);
DESCRIPTION
The IEEE 754 standard defines rounding precision modes for systems that always deliver intermediate results to destinations in extended
double precision format. These modes allow such systems to deliver correctly rounded single and double precision results (in the absence of
underflow and overflow) with only one rounding.
The fesetprec() function sets the current rounding precision to the precision specified by prec, which must be one of the following values
defined in <fenv.h>:
FE_FLTPREC round to single precision
FE_DBLPREC round to double precision
FE_LDBLPREC round to extended double precision
The default rounding precision when a program starts is FE_LDBLPREC.
The fegetprec() function returns the current rounding precision.
RETURN VALUES
The fesetprec() function returns a non-zero value if the requested rounding precision is established and 0 otherwise.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
|Architecture |Intel (see below) |
|Availability |SUNWlibms |
|Interface Stability |Stable |
|MT-Level |MT-Safe |
+-----------------------------+-----------------------------+
These functions are not available on SPARC systems because SPARC processors deliver intermediate results to destinations in single or dou-
ble format as determined by each floating point instruction.
SEE ALSO fegetenv(3M), fesetround(3M), attributes(5)
Numerical Computation Guide
SunOS 5.10 1 Oct 2003 fesetprec(3M)
Check Out this Related Man Page
FPGETMASK(3) BSD Library Functions Manual FPGETMASK(3)NAME
fpgetmask, fpgetprec, fpgetround, fpgetsticky, fpsetmask, fpsetprec, fpsetround, fpsetsticky -- IEEE FP mode control
LIBRARY
Standard C Library (libc, -lc)
SYNOPSIS
#include <ieeefp.h>
fp_except_t
fpgetmask(void);
fp_prec_t
fpgetprec(void);
fp_rnd_t
fpgetround(void);
fp_except_t
fpgetsticky(void);
fp_except_t
fpsetmask(fp_except_t mask);
fp_prec_t
fpsetprec(fp_prec_t prec);
fp_rnd_t
fpsetround(fp_rnd_t rnd_dir);
fp_except_t
fpsetsticky(fp_except_t sticky);
DESCRIPTION
A rounding mode fp_rnd_t is one of:
FP_RZ rounding towards zero
FP_RM rounding down to (Minus infinity)
FP_RN rounding to nearest
FP_RP rounding down to (Plus infinity)
The default mode is FP_RN.
An fp_except_t value is a bitmask specifying an exception type and containing any of the values listed below.
FP_X_INV Invalid Operation
FP_X_DZ Division by zero
FP_X_OFL Overflow
FP_X_UFL Underflow
FP_X_IMP Imprecision (inexact)
FP_X_IOV Integer Overflow
An fp_prec_t specifies the precision of the floating point operations listed below.
FP_PS 24 bit (single-precision)
FP_PRS reserved
FP_PD 53 bit (double-precision)
FP_PE 64 bit (extended-precision)
The fpsetmask() function will set the current exception mask, i.e., it will cause future operations with the specified result status to raise
the SIGFPE exception. The fpgetmask() function will return the current exception mask.
The fpgetprec() function will return the current floating point precision. The fpsetprec() function will set the floating point precision
and will return the previous precision.
The fpsetround() function will cause future operations to use the specified dynamic rounding mode. The fpgetround() function will return the
current rounding mode.
Note: On some architectures, instructions can optionally specify static rounding modes and exception enables that will supersede the speci-
fied dynamic mode. On other architectures, these features may not be fully supported.
A ``sticky'' status word may be maintained in which a bit is set every time an exceptional floating point condition is encountered, whether
or not a SIGFPE is generated. The fpsetsticky() function will set or clear the specified exception history bits. The fpgetsticky() function
will return the exception history bits.
RETURN VALUES
The fpgetround() and fpsetround() functions return the (previous) rounding mode. The fpgetmask(), fpsetmask(), fpgetsticky(), and
fpsetsticky() functions return the (previous) exception mask and exception history bits.
SEE ALSO sigaction(2), fenv(3)BUGS
There is no way to return an unsupported value. Not all processors support all the modes. These interfaces are deprecated and the ones in
fenv(3) should be used, although the interfaces in fenv(3) don't support getting or setting the precision.
BSD March 26, 2011 BSD