man.bsd.lv manual page server

Manual Page Search Parameters
FEGETENV(3) Library Functions Manual FEGETENV(3)

fegetenv, feholdexcept, fesetenv, feupdateenvfloating-point environment save and restore

library “libm”

#include <fenv.h>

#pragma STDC FENV_ACCESS ON

int
fegetenv(fenv_t *envp);

int
feholdexcept(fenv_t *envp);

int
fesetenv(const fenv_t *envp);

int
feupdateenv(const fenv_t *envp);

The floating-point environment includes exception flags and masks, the current rounding mode, and other architecture-specific settings. However, it does not include the floating-point register file.

The () function stores the current floating-point environment in the object pointed to by envp, whereas feholdexcept() saves the current environment, then clears all exception flags and masks all floating-point exceptions.

The () function restores a previously saved environment. The () function restores a saved environment as well, but it also raises any exceptions that were set in the environment it replaces.

The () function is often used with () or fesetenv() to suppress spurious exceptions that occur as a result of intermediate computations. An example in fenv(3) demonstrates how to do this.

The fegetenv(), feholdexcept(), fesetenv(), and feupdateenv() functions return 0 if they succeed, and non-zero otherwise.

feclearexcept(3), fenv(3), feraiseexcept(3), fesetenv(3), fetestexcept(3), fpgetmask(3), fpgetprec(3), fpsetmask(3), fpsetprec(3)

The fegetenv(), feholdexcept(), fesetenv(), and feupdateenv() functions conform to ISO/IEC 9899:1999 (“ISO C99”).

These routines first appeared in FreeBSD 5.3.

May 8, 2004 FreeBSD-12.0