Skip to content

Commit 2a6c260

Browse files
committed
check for IEEE 754 compliance
1 parent f23ced2 commit 2a6c260

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

include/fast_float/float_common.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,30 +1258,46 @@ fastfloat_really_inline constexpr uint64_t min_safe_u64(int base) {
12581258

12591259
static_assert(std::is_same<equiv_uint_t<double>, uint64_t>::value,
12601260
"equiv_uint should be uint64_t for double");
1261+
static_assert(std::numeric_limits<double>::is_iec559,
1262+
"double must fulfill the requirements of IEC 559 (IEEE 754)");
12611263

12621264
static_assert(std::is_same<equiv_uint_t<float>, uint32_t>::value,
12631265
"equiv_uint should be uint32_t for float");
1266+
static_assert(std::numeric_limits<float>::is_iec559,
1267+
"float must fulfill the requirements of IEC 559 (IEEE 754)");
12641268

12651269
#ifdef __STDCPP_FLOAT64_T__
12661270
static_assert(std::is_same<equiv_uint_t<std::float64_t>, uint64_t>::value,
12671271
"equiv_uint should be uint64_t for std::float64_t");
1272+
static_assert(
1273+
std::numeric_limits<std::float64_t>::is_iec559,
1274+
"std::float64_t must fulfill the requirements of IEC 559 (IEEE 754)");
12681275
#endif
12691276

12701277
#ifdef __STDCPP_FLOAT32_T__
12711278
static_assert(std::is_same<equiv_uint_t<std::float32_t>, uint32_t>::value,
12721279
"equiv_uint should be uint32_t for std::float32_t");
1280+
static_assert(
1281+
std::numeric_limits<std::float32_t>::is_iec559,
1282+
"std::float32_t must fulfill the requirements of IEC 559 (IEEE 754)");
12731283
#endif
12741284

12751285
#ifdef __STDCPP_FLOAT16_T__
12761286
static_assert(
12771287
std::is_same<binary_format<std::float16_t>::equiv_uint, uint16_t>::value,
12781288
"equiv_uint should be uint16_t for std::float16_t");
1289+
static_assert(
1290+
std::numeric_limits<std::float16_t>::is_iec559,
1291+
"std::float16_t must fulfill the requirements of IEC 559 (IEEE 754)");
12791292
#endif
12801293

12811294
#ifdef __STDCPP_BFLOAT16_T__
12821295
static_assert(
12831296
std::is_same<binary_format<std::bfloat16_t>::equiv_uint, uint16_t>::value,
12841297
"equiv_uint should be uint16_t for std::bfloat16_t");
1298+
static_assert(
1299+
std::numeric_limits<std::bfloat16_t>::is_iec559,
1300+
"std::bfloat16_t must fulfill the requirements of IEC 559 (IEEE 754)");
12851301
#endif
12861302

12871303
constexpr chars_format operator~(chars_format rhs) noexcept {

0 commit comments

Comments
 (0)