FEGETENV(3) | Library Functions Manual | FEGETENV(3)

# NAME

`fegetenv`, `feholdexcept`, `fesetenv`, `feupdateenv` — manage floating-point environment

# SYNOPSIS

Math Library (libm, -lm)
`#include <fenv.h>`

int
`fegetenv`(fenv_t *envp);

int
`feholdexcept`(fenv_t *envp);

int
`fesetenv`(const fenv_t *envp);

int
`feupdateenv`(const fenv_t *envp);

# DESCRIPTION

These functions manage the floating-point environment — status flags, rounding direction modes and exception masks — as one entity. The envp input argument is an object representing the floating-point environment. The macro `FE_DFL_ENV` represents the default floating-point environment — the one installed at program startup.

The `fegetenv`() function stores the current floating-point environment in the object pointed to by envp.

The `feholdexcept`() function saves the current floating-point environment in the object pointed to by envp, clears the floating-point status flags, and then installs a non-stop (continue on floating-point exceptions) mode for all floating-point exceptions.

The `fesetenv`() function establishes the floating-point environment represented by the object pointed to by envp. The argument envp shall point to an object set by a call to `fegetenv`() or `feholdexcept`(), or equal the macro `FE_DFL_ENV`. Note that `fesetenv`() merely installs the state of the floating-point status flags represented through its argument, and does not raise these floating-point exceptions.

The `feupdateenv`() function saves the currently raised floating-point exceptions in its automatic storage, installs the floating-point environment represented by the object pointed to by envp, and then raises the saved floating-point exceptions. The argument envp shall point to an object set by a call to `feholdexcept`() or `fegetenv`(), or equal the macro `FE_DFL_ENV`.

# RETURN VALUES

The `fegetenv`(), `feholdexcept`(), `fesetenv`(), and `feupdateenv`() functions return zero on success, and non-zero if an error occurred.

# SEE ALSO

feclearexcept(3), feenableexcept(3), fegetround(3)

# STANDARDS

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

The return types for `fegetenv`(), `fesetenv`(), and `feupdateenv`() are int for alignment with ISO/IEC 9899:1999 (“ISO C99”) Defect Report #202.

June 7, 2025 | Debian