From 2a6c2604b5489933c6f7644e8c331207c5944d9d Mon Sep 17 00:00:00 2001 From: Anders Dalvander Date: Wed, 4 Dec 2024 09:34:34 +0100 Subject: [PATCH] check for IEEE 754 compliance --- include/fast_float/float_common.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/fast_float/float_common.h b/include/fast_float/float_common.h index 8a1e6c3..8947ce2 100644 --- a/include/fast_float/float_common.h +++ b/include/fast_float/float_common.h @@ -1258,30 +1258,46 @@ fastfloat_really_inline constexpr uint64_t min_safe_u64(int base) { static_assert(std::is_same, uint64_t>::value, "equiv_uint should be uint64_t for double"); +static_assert(std::numeric_limits::is_iec559, + "double must fulfill the requirements of IEC 559 (IEEE 754)"); static_assert(std::is_same, uint32_t>::value, "equiv_uint should be uint32_t for float"); +static_assert(std::numeric_limits::is_iec559, + "float must fulfill the requirements of IEC 559 (IEEE 754)"); #ifdef __STDCPP_FLOAT64_T__ static_assert(std::is_same, uint64_t>::value, "equiv_uint should be uint64_t for std::float64_t"); +static_assert( + std::numeric_limits::is_iec559, + "std::float64_t must fulfill the requirements of IEC 559 (IEEE 754)"); #endif #ifdef __STDCPP_FLOAT32_T__ static_assert(std::is_same, uint32_t>::value, "equiv_uint should be uint32_t for std::float32_t"); +static_assert( + std::numeric_limits::is_iec559, + "std::float32_t must fulfill the requirements of IEC 559 (IEEE 754)"); #endif #ifdef __STDCPP_FLOAT16_T__ static_assert( std::is_same::equiv_uint, uint16_t>::value, "equiv_uint should be uint16_t for std::float16_t"); +static_assert( + std::numeric_limits::is_iec559, + "std::float16_t must fulfill the requirements of IEC 559 (IEEE 754)"); #endif #ifdef __STDCPP_BFLOAT16_T__ static_assert( std::is_same::equiv_uint, uint16_t>::value, "equiv_uint should be uint16_t for std::bfloat16_t"); +static_assert( + std::numeric_limits::is_iec559, + "std::bfloat16_t must fulfill the requirements of IEC 559 (IEEE 754)"); #endif constexpr chars_format operator~(chars_format rhs) noexcept {