Commit 675bafff authored by Peter W. Draper's avatar Peter W. Draper
Browse files

Merge branch 'UBsan_random' into 'master'

UBsan fix for RNG

Closes #606

See merge request !1006
parents 9f675abe 44168020
......@@ -108,7 +108,7 @@ INLINE static double inl_erand48(uint16_t xsubi[3]) {
temp.ieee.negative = 0;
temp.ieee.exponent = IEEE754_DOUBLE_BIAS;
temp.ieee.mantissa0 = (xsubi[2] << 4) | (xsubi[1] >> 12);
temp.ieee.mantissa1 = ((xsubi[1] & 0xfff) << 20) | (xsubi[0] << 4);
temp.ieee.mantissa1 = (((uint32_t)xsubi[1] & 0xfff) << 20) | (xsubi[0] << 4);
/* Please note the lower 4 bits of mantissa1 are always 0. */
return temp.d - 1.0;
......
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