write_rnd(3) Library Functions Manual write_rnd(3)NAME
write_rnd, read_rnd - Sets and returns IEEE dynamic rounding mode for floating-point operations
LIBRARY
Standard C Library (libc.so, libc.a)
SYNOPSIS
#include <float.h>
unsigned int write_rnd(
unsigned int rnd);
unsigned int read_rnd();
DESCRIPTION
The write_rnd function sets the dynamic rounding mode in the floating-point control register (fpcr) for IEEE floating-point operations and
returns the previous dynamic rounding mode. Dynamic rounding mode for IEEE floating-point operations is enabled for code generated by the
C compiler by specifying -fprm d to cc(1), and by using the d floating-point instruction operator in assembly language code.
Specify rnd as one of the following constants defined in float.h
---------------------------------------------------
Constant Meaning
---------------------------------------------------
FP_RND_RZ Round toward zero (chopped rounding)
FP_RND_RN Round toward nearest (normal rounding)
FP_RND_RP Round toward plus infinity
FP_RND_RM Round toward minus infinity
---------------------------------------------------
The read_rnd function returns the current dynamic rounding mode for floating-point operations.
RETURN VALUES
The write_rnd function returns the previous IEEE floating-point rounding mode. The read_rnd function returns the current IEEE floating-
point rounding mode.
RELATED INFORMATION
Commands: cc(1).
Files: float.h.
Assembly Language Programmer's Guide.
Alpha Architecture Reference Manual.
IEEE Standard for Binary Floating-Point Arithmetic delim off
write_rnd(3)
Check Out this Related Man Page
fegetround(3M)fegetround(3M)NAME
fegetround() - get floating-point rounding direction mode
SYNOPSIS DESCRIPTION
The function gets the current rounding direction, as specified by the IEEE 754 (IEC 60559) floating-point standard.
The default rounding direction mode is round to nearest
USAGE
To use this function, compile either with the default option or with the and options. Make sure your program includes
For HP Integrity servers, specify on the compiler command line or place the call to this function under the effect of an affirmative
pragma:
If the pragma is placed outside of any top-level declarations in a file, the pragma will apply to all declarations in the compilation fol-
lowing the pragma until another pragma is encountered or until the end of the file is reached.
If the pragma is placed at the beginning of a block (compound statement), the pragma will apply until another pragma is encountered or
until the end of the block is reached.
For PA-RISC, you might need to use the compiler option in order to prevent optimizations that can undermine the specified behavior of this
function.
Link in the math library by specifying on the compiler or linker command line.
For more information, see the at the following site:
RETURN VALUE
The function returns the value of the rounding direction macro representing the current rounding direction. The return value will match
one of the following macros, which are defined in
Round to nearest. If the two nearest representable are equally near,
the one with its least significant bit zero is delivered.
Round upwards (towards +infinity).
Round downwards (towards -infinity).
Round toward zero.
ERRORS
No errors are defined.
EXAMPLES
Save, set, and restore the rounding direction.
SEE ALSO fesetround(3M), fenv(5).
STANDARDS CONFORMANCE
: ISO/IEC C99 (including Annex F, ``IEC 60559 floating-point arithmetic'')
fegetround(3M)