Commit f8b53a82 authored by Richard M. Stallman's avatar Richard M. Stallman
Browse files

(random): Use rand differently, and distinguish BSD/USG.

parent 8ee9ba64
......@@ -2612,8 +2612,15 @@ random ()
#ifdef HAVE_RAND48
return rand48 ();
#else
/* Arrange to return a range centered on zero. */
return (rand () << 15) + rand () - (1 << 29);
/* The BSD rand returns numbers in the range of 0 to 2e31 - 1,
with unusable least significant bits. The USG rand returns
numbers in the range of 0 to 2e15 - 1, all usable. Let us
build a usable 30 bit number from either. */
#ifdef USG
return (rand () << 15) + rand ();
#else
return (rand () & 0x3fff8000) + (rand () >> 16);
#endif
#endif
}
......
Markdown is supported
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