Commit 8ac8d512 authored by Christoph Conrads's avatar Christoph Conrads
Browse files

Uniform real: adapt code to 32-bit systems

parent 267130af
......@@ -83,7 +83,18 @@ Unsigned draw_exponent(Unsigned a, Unsigned b, Generator* p_generator)
static_assert(std::is_integral<result_t>::value, "");
static_assert(not std::is_signed<result_t>::value, "");
static_assert(std::is_same<Unsigned, uint_t>::value, "");
static_assert(not std::is_signed<uint_t>::value, "");
// One may use small unsigned integer types to test the behavior when there
// are more bins than digits. This assertion checks that we are not
// /accidentally/ using an integer type wider than `Unsigned`.
static_assert(
std::numeric_limits<std::size_t>::digits
< std::numeric_limits<result_t>::digits
or std::is_same<Unsigned, uint_t>::value,
""
);
assert(a < b);
......@@ -95,7 +106,7 @@ Unsigned draw_exponent(Unsigned a, Unsigned b, Generator* p_generator)
constexpr auto one = uint_t{1};
constexpr auto num_digits = uint_t(std::numeric_limits<uint_t>::digits);
// the number of bins for *normal* numbers
auto num_bins = b - std::max(one, a) + 0u;
auto num_bins = b - std::max(Unsigned{1}, a) + 0u;
auto denormal_p = a == 0;
if(num_bins <= num_digits)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment