fix(Math): guard 64-bit precision shift in checked_cast for long double

This commit is contained in:
faumaray committed 2026-11-24 02:55:35 +03:00
1 parent 91e2beb5d4
commit 6cac781f3a
2 files changed
+30 -18

No files matched your search

+8
View File
@@ -344,6 +344,14 @@ Void::Testing::Test checked_cast_int_to_float()
Void::Testing::expect_eq(
*checked_cast<double>(u64_max, Rounding::toward_zero),
std::ldexp(1.0, 64) - 2048.0);
const auto ld_u64 = checked_cast<long double>(u64_max);
if constexpr (std::numeric_limits<long double>::digits >= 64) {
Void::Testing::expect(ld_u64.has_value());
Void::Testing::expect(*ld_u64 == static_cast<long double>(u64_max));
} else {
Void::Testing::expect(ld_u64 == std::unexpected{Error::Inexact});
}
}
Void::Testing::Test checked_cast_float_to_int_boundaries_and_rounding()