diff options
| author | Andrey A. Chernov <ache@FreeBSD.org> | 2003-02-03 10:22:12 +0000 |
|---|---|---|
| committer | Andrey A. Chernov <ache@FreeBSD.org> | 2003-02-03 10:22:12 +0000 |
| commit | 2f5ef51de2995dce0f81042d954bb9c8f00e7d9f (patch) | |
| tree | d0cfc71d1b2ec12652d4f2afb24ec1c659571650 /lib/libc/stdlib/random.c | |
| parent | f3cf900844d81871f07616d1f4c5cd9dd18db31b (diff) | |
Notes
Diffstat (limited to 'lib/libc/stdlib/random.c')
| -rw-r--r-- | lib/libc/stdlib/random.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/libc/stdlib/random.c b/lib/libc/stdlib/random.c index b3a1e11d1a2d..82af94c851fc 100644 --- a/lib/libc/stdlib/random.c +++ b/lib/libc/stdlib/random.c @@ -236,10 +236,13 @@ static inline long good_rand (x) */ long hi, lo; + /* Can't be initialized with 0, so use another value. */ + if (x == 0) + x = 123459876; hi = x / 127773; lo = x % 127773; x = 16807 * lo - 2836 * hi; - if (x <= 0) + if (x < 0) x += 0x7fffffff; return (x); #endif /* !USE_WEAK_SEEDING */ |
