summaryrefslogtreecommitdiff
path: root/stdlib/erand48_r.c
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/erand48_r.c')
-rw-r--r--stdlib/erand48_r.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/stdlib/erand48_r.c b/stdlib/erand48_r.c
index b3f8b634e3..85393b79f6 100644
--- a/stdlib/erand48_r.c
+++ b/stdlib/erand48_r.c
@@ -42,12 +42,18 @@ __erand48_r (xsubi, buffer, result)
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);
- /* Please note the lower 4 bits of mantissa1 are always 0. */
- *result = temp.d - 1.0;
+#elif USHRT_MAX == 2147483647
+ temp.ieee.negative = 0;
+ temp.ieee.exponent = IEEE754_DOUBLE_BIAS;
+ temp.ieee.mantissa0 = (xsubi[1] << 4) | (xsubi[0] >> 28);
+ temp.ieee.mantissa1 = ((xsubi[0] & 0xfffffff) << 4);
#else
# error Unsupported size of short int
#endif
+ /* Please note the lower 4 bits of mantissa1 are always 0. */
+ *result = temp.d - 1.0;
+
return 0;
}
weak_alias (__erand48_r, erand48_r)