# Floating-point extensions part 1: binary floating-point arithmetic

> C++ Atlas: `cppatlas.com/w/c/experimental/fpext1` | Source: https://en.cppreference.com/w/c/experimental/fpext1 | Domain: Technical specifications

Floating-point extensions for C - Part 1: Binary floating-point arithmetic, ISO/IEC TS 18661-1:2014, defines the following new components for the C standard library, as recommended by ISO/IEC/IEEE 60559:2011 (the current revision of…

## Official Specification Summary (cppreference)

Floating-point extensions for C - Part 1: Binary floating-point arithmetic, ISO/IEC TS 18661-1:2014, defines the following new components for the C standard library, as recommended by ISO/IEC/IEEE 60559:2011 (the current revision of IEEE-754)

- `__STDC_IEC_60559_BFP__`: integer constant of type `long` and value `201ymmL`, replaces `__STDC_IEC_559__` (macro constant)
- `__STDC_IEC_60559_COMPLEX__`: integer constant of type `long` and value `201ymmL`, replaces `__STDC_IEC_559_COMPLEX__` (macro constant)

Defined in header `<limits.h>`

- `CHAR_WIDTH SCHAR_WIDTH UCHAR_WIDTH` (FP Ext 1 TS), `SHRT_WIDTH USHRT_WIDTH`, `INT_WIDTH UINT_WIDTH`, `LONG_WIDTH ULONG_WIDTH`, `LLONG_WIDTH ULLONG_WIDTH`: width, in bits, of the corresponding type (macro constant)

Defined in header `<float.h>`

- `CR_DECIMAL_DIG` (FP Ext 1 TS): conversions between all supported binary floating-point types and character sequences with at most CR_DECIMAL_DIG significant decimal digits are correctly rounded (this is at least DECIMAL_DIG + 3) (macro constant)

Defined in header `<fenv.h>`

- `femode_t` (FP Ext 1 TS): collection of dynamic floating-point control modes supported by the implementation, including the dynamic rounding direction mode (typedef)
- `FE_DFL_MODE` (FP Ext 1 TS): pointer to the default femode_t (macro constant)
- `FE_SNANS_ALWAYS_SIGNAL` (FP Ext 1 TS): defined (as integer constant 1) if sNaN arguments cause the functions that suppress qNaNs, like `hypot` or `fmax`, to raise FE_INVALID and return a qNaN (macro constant)
- `fesetexcept` (FP Ext 1 TS): sets the specified floating-point exception flags without causing any side-effects that raising them would (function)
- `fetestexceptflag` (FP Ext 1 TS): tests if given flags are in a saved representation of the floating-point exception flags (function)
- `fegetmode` (FP Ext 1 TS), `fesetmode`: gets and sets all the implementation’s dynamic floating-point control modes collectively (function)

Defined in header `<stdint.h>`

- `INTn_WIDTH UINTn_WIDTH` (FP Ext 1 TS), `INT_LEASTn_WIDTH UINT_LEASTn_WIDTH`, `INT_FASTn_WIDTH UINT_FASTn_WIDTH`, `INTPTR_WIDTH UINTPTR_WIDTH`, `INTMAX_WIDTH UINTMAX_WIDTH`, `PTRDIFF_WIDTH`, `SIG_ATOMIC_WIDTH`, `SIZE_WIDTH`, `WCHAR_WIDTH WINT_WIDTH`: width, in bits, of the corresponding type (macro constant)

Defined in header `<stdlib.h>`

- `strfromd` (FP Ext 1 TS), `strfromf`, `strfroml`: convert a single foating-point number to string using the specified snprintf format (function)

Defined in header `<math.h>`

- `FP_INT_UPWARD` (FP Ext 1 TS), `FP_INT_DOWNWARD`, `FP_INT_TOWARDZERO`, `FP_INT_TONEARESTFROMZERO`, `FP_INT_TONEAREST`: rounding direction for the functions ceil, floor, trunc, round, and roundeven, suitable for use with fromfp family of functions (macro constant)
- `FP_LLOGB0` (FP Ext 1 TS): value returned by `llogb` if the argument is zero (macro constant)
- `FP_LLOGBNAN` (FP Ext 1 TS): value returned by `llogb` if the argument is NaN (macro constant)
- `SNANF` (FP Ext 1 TS), `SNAN`, `SNANL`: represents a signalling NaN for float, double, long double respectively (macro constant)
- `FP_FAST_FADD FP_FAST_FADDL FP_FAST_DADDL` (FP Ext 1 TS), `FP_FAST_FSUB FP_FAST_FSUBL FP_FAST_DSUBL`, `FP_FAST_FMUL FP_FAST_FMULL FP_FAST_DMULL`, `FP_FAST_FDIV FP_FAST_FDIVL FP_FAST_DDIVL`, `FP_FAST_FFMA FP_FAST_FFMAL FP_FAST_DFMAL`, `FP_FAST_FSQRT FP_FAST_FSQRTL FP_FAST_DSQRTL`: if defined, indicates that the corresponding function executes faster than the equivalent function in a larger type followed by a cast to target type (macro constant)
- `iseqsig` (FP Ext 1 TS): (function macro)
- `iscanonical` (FP Ext 1 TS): tests if the floating-point value is canonical (function macro)
- `issignaling` (FP Ext 1 TS): tests if the floating-point value is a signalling NaN (function macro)
- `issubnormal` (FP Ext 1 TS): tests if the floating-point value is subnormal (function macro)
- `iszero` (FP Ext 1 TS): tests if the floating-point value is a zero (positive, negative, unsigned) (function macro)
- `fromfp` (FP Ext 1 TS), `fromfpf`, `fromfpl`: round to signed integer using the specified rounding direction (function)
- `ufromfp` (FP Ext 1 TS), `ufromfpf`, `ufromfpl`: round to unsigned integer using the specified rounding direction (function)
- `fromfpx` (FP Ext 1 TS), `fromfpxf`, `fromfpxl`: round to signed integer using the specified rounding direction, reporting inexactness (function)
- `ufromfpx` (FP Ext 1 TS), `ufromfpxf`, `ufromfpxl`: round to unsigned integer using the specified rounding direction, reporting inexactness (function)
- `roundeven` (FP Ext 1 TS), `roundevenf`, `roundevenl`: rounds to nearest, halfway cases to even (function)
- `llogb` (FP Ext 1 TS), `llogbf`, `llogbl`: equivalent to `logb` except the return type is `long` (function)
- `fmaxmag` (FP Ext 1 TS), `fmaxmagf`, `fmaxmagl`: returns the value of their argument of maximum magnitude (function)
- `fminmag` (FP Ext 1 TS), `fminmagf`, `fminmagl`: returns the value of their argument of minimum magnitude (function)
- `nextup` (FP Ext 1 TS), `nextupf`, `nextupl`: returns the next greater representable floating-point value (function)
- `nextdown` (FP Ext 1 TS), `nextdownf`, `nextdown l`: returns the next smaller representable floating-point value (function)
- `fadd` (FP Ext 1 TS), `faddl`, `daddl`: calculates x+y as if in infinite precision and rounded once to target type (function)
- `fsub` (FP Ext 1 TS), `fsubl`, `dsubl`: calculates x-y as if in infinite precision and rounded once to target type (function)
- `fmul` (FP Ext 1 TS), `fmull`, `dmull`: calculates x*y as if in infinite precision and rounded once to target type (function)
- `fdiv` (FP Ext 1 TS), `fdivl`, `ddivl`: calculates x/y as if in infinite precision and rounded once to target type (function)
- `ffma` (FP Ext 1 TS), `ffmal`, `dfmal`: calculates the same as `fma` as if in infinite precision and rounded once to target type (function)
- `fsqrt` (FP Ext 1 TS), `fsqrtl`, `dsqrtl`: calculates the same as `sqrt` as if in infinite precision and rounded once to target type (function)
- `totalorder` (FP Ext 1 TS), `totalorderf`, `totalorderl`: orders two floating-point values using the ISO 60559 total order relation (function)
- `totalordermag` (FP Ext 1 TS), `totalordermagf`, `totalordermagl`: orders the magnitudes of two floating-point values using the ISO 60559 total order relation (function)
- `canonicalize` (FP Ext 1 TS), `canonicalizef`, `canonicalizel`: obtains the ISO 60559 canonical binary encoding of the given floating-point value (function)
- `getpayload` (FP Ext 1 TS), `getpayloadf`, `getpayloadl`: extracts the payload from the given NaN value (function)
- `setpayload` (FP Ext 1 TS), `setpayloadf`, `setpayloadl`: creates a quiet NaN with the specified payload (function)
- `setpayloadsig` (FP Ext 1 TS), `setpayloadsigf`, `setpayloadsigl`: creates a signalling NaN with the specified payload (function)

Defined in header `<tgmath.h>`

- `roundeven` (FP Ext 1 TS): generic overload of `roundeven` (function)
- `llogb` (FP Ext 1 TS): generic overload of `llogb` (function)
- `fmaxmag` (FP Ext 1 TS): generic overload of `fmaxmag` (function)
- `fminmag` (FP Ext 1 TS): generic overload of `fminmag` (function)
- `nextup` (FP Ext 1 TS): generic overload of `nextup` (function)
- `nextdown` (FP Ext 1 TS): generic overload of `nextdown` (function)
- `fromfp` (FP Ext 1 TS): generic overload of `fromfp` (function)
- `ufromfp` (FP Ext 1 TS): generic overload of `ufromfp` (function)
- `fromfpx` (FP Ext 1 TS): generic overload of `fromfpx` (function)
- `ufromfpx` (FP Ext 1 TS): generic overload of `ufromfpx` (function)
- `nextdown` (FP Ext 1 TS): generic overload of `nextdown` (function)
- `totalorder` (FP Ext 1 TS): generic overload of `totalorder` (function)
- `totalordermag` (FP Ext 1 TS): generic overload of `totalordermag` (function)
- `fadd` (FP Ext 1 TS): generic overload of `fadd` (function)
- `dadd` (FP Ext 1 TS): generic overload of `dadd` (function)
- `fsub` (FP Ext 1 TS): generic overload of `fsub` (function)
- `dsub` (FP Ext 1 TS): generic overload of `dsub` (function)
- `fmul` (FP Ext 1 TS): generic overload of `fmul` (function)
- `dmul` (FP Ext 1 TS): generic overload of `dmul` (function)
- `fdiv` (FP Ext 1 TS): generic overload of `fdiv` (function)
- `ddiv` (FP Ext 1 TS): generic overload of `ddiv` (function)
- `ffma` (FP Ext 1 TS): generic overload of `ffma` (function)
- `dfma` (FP Ext 1 TS): generic overload of `dfma` (function)
- `fsqrt` (FP Ext 1 TS): generic overload of `fsqrt` (function)
- `dsqrt` (FP Ext 1 TS): generic overload of `dsqrt` (function)

### Notes

The standard C macros `__STDC_IEC_559__` and `__STDC_IEC_559_COMPLEX__` are made obsolete by this technical specification.

All functions and macros added to the C library by this extension are only declared if a macro `__STDC_WANT_IEC_60559_BFP_EXT__` is defined before the corresponding header is included.

Besides additions to the standard library, ISO/IEC TS 18661-1:2014 makes a number of changes to the core language, notably splitting floating-point control between static (controlled by the new `#pragma STDC FENV_ROUND`), and dynamic (controlled by `fesetround`). Most math.h functions respect the static rounding mode, if set, over the dynamic rounding mode.

> Note: This section is incomplete Reason: add to the pragma page or describe the pragma in full here?

---
Attribution: content from https://en.cppreference.com/w/c/experimental/fpext1 (cppreference.com), licensed under CC-BY-SA 3.0 and GFDL. Modified: converted to markdown, study notes added. Offline snapshot of 9 February 2025.