diff options
author | Eric Andersen <andersen@codepoet.org> | 2000-10-09 20:06:30 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2000-10-09 20:06:30 +0000 |
commit | c1fe19d4c1db610692365472a90f4661e48449c1 (patch) | |
tree | d0b0219ffca3c4c4256f55c4aea4513e43d6aecd /libc/stdlib/rand.c | |
parent | 9efafb8bbc7408b04643dcd53825d971577b4d9d (diff) |
Bug ugly formatting update
Diffstat (limited to 'libc/stdlib/rand.c')
-rw-r--r-- | libc/stdlib/rand.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/libc/stdlib/rand.c b/libc/stdlib/rand.c index 4bf98d5bc..b5c5cb764 100644 --- a/libc/stdlib/rand.c +++ b/libc/stdlib/rand.c @@ -12,13 +12,13 @@ static unsigned int sseed = 0; int rand() { - return ( sseed = (((sseed+1L)*75L)%65537L)-1 ) & MAXINT; + return (sseed = (((sseed + 1L) * 75L) % 65537L) - 1) & MAXINT; } void srand(seed) unsigned int seed; { - sseed=seed; + sseed = seed; } #else @@ -32,6 +32,7 @@ unsigned int seed; static int seed1 = 1; static int seed2 = 1; static int seed3 = 1; + #define MAXINT (((unsigned)-1)>>1) #define CRANK(a,b,c,m,s) \ @@ -41,21 +42,22 @@ static int seed3 = 1; int rand() { - register int q; - CRANK(206, 157, 31, 32363, seed1); - CRANK(217, 146, 45, 31727, seed2); - CRANK(222, 142, 133, 31657, seed3); + register int q; + + CRANK(206, 157, 31, 32363, seed1); + CRANK(217, 146, 45, 31727, seed2); + CRANK(222, 142, 133, 31657, seed3); - return seed1^seed2^seed3; + return seed1 ^ seed2 ^ seed3; } void srand(seed) unsigned int seed; { - seed &= MAXINT; - seed1= seed%32362 + 1; - seed2= seed%31726 + 1; - seed3= seed%31656 + 1; + seed &= MAXINT; + seed1 = seed % 32362 + 1; + seed2 = seed % 31726 + 1; + seed3 = seed % 31656 + 1; } #endif |