From adfe682eb0d77c6afc751f5e407d9da39623c24e Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Fri, 16 Dec 2016 23:19:27 -0500 Subject: [PATCH] fix mrand48/jrand48 return value on 64-bit archs POSIX specifies the result to have signed 32-bit range. on 32-bit archs, the implicit conversion to long achieved the desired range already, but when long is 64-bit, a cast is needed. patch by Ed Schouten. --- src/prng/mrand48.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/prng/mrand48.c b/src/prng/mrand48.c index ee650fc3..0519d667 100644 --- a/src/prng/mrand48.c +++ b/src/prng/mrand48.c @@ -6,7 +6,7 @@ extern unsigned short __seed48[7]; long jrand48(unsigned short s[3]) { - return __rand48_step(s, __seed48+3) >> 16; + return (int32_t)(__rand48_step(s, __seed48+3) >> 16); } long mrand48(void) -- 2.25.1