Mercurial > emacs
comparison src/sysdep.c @ 8368:0c30bec316c6
(random): Use rand differently, and distinguish BSD/USG.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 28 Jul 1994 12:50:34 +0000 |
parents | f9d8f778f73b |
children | 83a8062ca215 |
comparison
equal
deleted
inserted
replaced
8367:31ceccb9982d | 8368:0c30bec316c6 |
---|---|
2610 random () | 2610 random () |
2611 { | 2611 { |
2612 #ifdef HAVE_RAND48 | 2612 #ifdef HAVE_RAND48 |
2613 return rand48 (); | 2613 return rand48 (); |
2614 #else | 2614 #else |
2615 /* Arrange to return a range centered on zero. */ | 2615 /* The BSD rand returns numbers in the range of 0 to 2e31 - 1, |
2616 return (rand () << 15) + rand () - (1 << 29); | 2616 with unusable least significant bits. The USG rand returns |
2617 numbers in the range of 0 to 2e15 - 1, all usable. Let us | |
2618 build a usable 30 bit number from either. */ | |
2619 #ifdef USG | |
2620 return (rand () << 15) + rand (); | |
2621 #else | |
2622 return (rand () & 0x3fff8000) + (rand () >> 16); | |
2623 #endif | |
2617 #endif | 2624 #endif |
2618 } | 2625 } |
2619 | 2626 |
2620 srandom (arg) | 2627 srandom (arg) |
2621 int arg; | 2628 int arg; |