|
| constexpr int | fpclassify (const float) noexcept |
| | a portable implementation of the std::fpclassify function based on the MUSL library (https://www.musl-libc.org).
|
| constexpr int | fpclassify (const double) noexcept |
| | a portable implementation of the std::fpclassify function based on the MUSL library (https://www.musl-libc.org)
|
| constexpr bool | isnan (const float) noexcept |
| | Determines if the given floating point number arg is a not-a-number (NaN) value.
|
| constexpr bool | isnan (const double) noexcept |
| | Determines if the given floating point number arg is a not-a-number (NaN) value.
|
| TFEL_HOST_DEVICE bool | isnan (const long double) noexcept |
| | Determines if the given floating point number arg is a not-a-number (NaN) value.
|
| constexpr bool | isfinite (const float) noexcept |
| | Determines if the given floating point number arg has finite value i.e. it is normal, subnormal or zero, but not infinite or NaN.
|
| constexpr bool | isfinite (const double) noexcept |
| | Determines if the given floating point number arg has finite value i.e. it is normal, subnormal or zero, but not infinite or NaN.
|
| TFEL_HOST_DEVICE bool | isfinite (const long double) noexcept |
| | Determines if the given floating point number arg has finite value i.e. it is normal, subnormal or zero, but not infinite or NaN.
|
| TFEL_HOST_DEVICE int | fpclassify (const long double) noexcept |
| | a portable implementation of the std::fpclassify function based on the MUSL library (https://www.musl-libc.org)
|
| template<ImmutableQuantityConcept QuantityType> |
| TFEL_HOST_DEVICE constexpr int | fpclassify (const QuantityType &q) noexcept |
| template<ImmutableQuantityConcept QuantityType> |
| TFEL_HOST_DEVICE constexpr bool | isnan (const QuantityType &q) noexcept |
| template<ImmutableQuantityConcept QuantityType> |
| TFEL_HOST_DEVICE constexpr bool | isfinite (const QuantityType &q) noexcept |
The C99 standard defines the fpclassify, isnan, isfinite functions to query some information about double precision floatting-point numbers (double):
- Following the IEEE754 standard, the fpclassify categorizes a floating point number into one of the following categories: zero, subnormal, normal, infinite, NaN (Not a Number). The return value returned for each category is respectively FP_ZERO, FP_SUBNORMAL, FP_NORMAL, FP_INFINITE and FP_NaN.
- The isnan function returns a boolean stating if its argument has a not-a-number (NaN) value.
- The isfinite function returns true if its argument falls into one of the following categories: zero, subnormal or normal.
The C++11 provides a set of overload for single precision (float) and extended precision (long double) floatting-point numbers.
Those functions are very handy to check the validity of a computation. However, those functions are not compatible with the use of the -ffast-math option of the GNU compiler which also implies the -ffinite-math-only option. This latter option allows optimizations for floating-point arithmetic that assume that arguments and results are finite numbers. As a consequence, when this option is enabled, the previous functions does not behave as expected. For example, isnan always returns false, whatever the value of its argument.
To overcome this issue, we have introduced in TFEL/Math the implementation of these functions provided by the musl library. Those implementations are compatible with the -ffast-math option of the GNU compiler. Those implementations are defined in the TFEL/Math/General/IEEE754.hxx header file in the tfel::math::ieee754 namespace.