Path: csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.lang.c
Subject: Re: srand(0)
Date: Wed, 07 Jan 2026 07:46:40 -0800
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <86344hpgrj.fsf@linuxsc.com>
References: <10ib0ka$3cgil$1@dont-email.me> <10ibava$2sora$1@dont-email.me> <10ibcub$25ihi$2@dont-email.me> <10ibu81$2sora$2@dont-email.me> <10ibvrm$25ihh$2@dont-email.me> <20251222204538.00003fc2@yahoo.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Date: Wed, 07 Jan 2026 15:46:44 +0000 (UTC)
Injection-Info: dont-email.me; posting-host="96c89593a79aadfcc4daf354c711affa"; logging-data="798811"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19J5B/na9XzC1tL57APDyO8V7/+ZEN27A4="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:U32V9ubxgZS9SuxiPX+0wgT2Bmc= sha1:+qDWeITkqzSWMdfcxzilJiffWJI=
Xref: csiph.com comp.lang.c:396268
Michael S writes:
[regarding rand() and srand()]
> Pay attention that C Standard only requires for the same seed to always
> produces the same sequence. There is no requirement that different
> seeds have to produce different sequences.
> So, for generator in your example, implementation like below would be
> fully legal. Personally, I wouldn't even consider it as particularly
> poor quality:
>
> void srand(unsigned seed ) { init = seed | 1;}
It seems better to do, for example,
void srand(unsigned seed ) { init = seed - !seed;}