Developer Guide and Reference

ID 767253
Date 10/31/2024
Public
Document Table of Contents

Floating-Point Environment

The floating-point environment is a collection of registers that control the behavior of the floating-point machine instructions and indicate the current floating-point status. The floating-point environment can include rounding mode controls, exception masks, flush-to-zero (FTZ) controls, exception status flags, and other floating-point related features.

The floating-point environment affects most floating-point operations; therefore, correct configuration to meet your specific needs is important. For example, the exception mask bits define which exceptional conditions will be raised as exceptions by the processor. In general, the default floating-point environment is set by the operating system. You don't need to configure the floating-point environment unless the default floating-point environment does not suit your needs.

There are several methods available to modify the default floating-point environment:

  • inline assembly
  • compiler built-in functions
  • library functions
  • command line options

By default the floating-point environment access is set to off. To enable floating-point environment access, set the STDC_FENV_ACCESS pragma to ON or set -fp-model=strict.

Changing the default floating-point environment affects runtime results only. This does not affect any calculations that are pre-computed at compile time.

If strict reproducibility and consistency are important do not change the floating point environment without also using either -fp-model strict (Linux*) or /fp:strict (Windows*) option or pragma fenv_access.