Correct error logic in test/test_convert_cpp_int_2_float.cpp.

Previously we were accidentally passing a negative value to the shift operator.
This commit is contained in:
jzmaddock
2021-12-13 18:20:16 +00:00
parent 6eec3d6d28
commit ae592ade3d

View File

@@ -69,11 +69,12 @@ void test_convert()
From from = generate_random<From>(bits);
To t1(from);
From b(t1);
if (bits > std::numeric_limits<To>::digits)
std::size_t m = msb(from);
if (m >= std::numeric_limits<To>::digits)
{
// For error <= 1ulp
// Note msb(from) returns one less than the number of bits in from:
From max_error = (From(1) << (msb(from) - std::numeric_limits<To>::digits));
From max_error = (From(1) << (m - std::numeric_limits<To>::digits));
BOOST_TEST_GE(max_error, abs(b - from));
if (max_error < abs(b - from))
// debugging help: