Path: csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: srand(0) Date: Tue, 23 Dec 2025 16:30:16 -0800 Organization: None to speak of Lines: 48 Message-ID: <87h5tg90x3.fsf@example.invalid> 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> <10ices7$25ihi$5@dont-email.me> <20251223111855.000035ba@yahoo.com> <10idosf$25ihh$4@dont-email.me> <20251223135031.000000b3@yahoo.com> <10if8lm$2sora$3@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Wed, 24 Dec 2025 00:30:17 +0000 (UTC) Injection-Info: dont-email.me; posting-host="fafb48b540a2fff724766d529c113127"; logging-data="714102"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18ndxE8gJYFEq5WBWPMtBjZ" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:Ef7QOZ/36uTVF+7OIDVAy35CISk= sha1:b0jcu1DMnKEhoJmOkOX2Y4qdb80= Xref: csiph.com comp.lang.c:395922 James Kuyper writes: > On 2025-12-23 06:50, Michael S wrote: >> On Tue, 23 Dec 2025 10:54:23 +0100 >> Janis Papanagnou wrote: >> >>> On 2025-12-23 10:18, Michael S wrote: > ... >>>> MT19937-64 is available out of the box(*) in C++. But not in C, >>>> unfortunately. >>> >>> This is really strange given that the name ("Mersenne Twister") is >>> that prominent. >>> >>> Looking that up I find at least "C" code for MT19937 in Wikipedia >>> https://de.wikipedia.org/wiki/Mersenne-Twister >>> It's based on 32 bit logic it seems; interpreting your "MT19937-64" >>> I assume you're looking for a 64 bit based version? >>> >> >> "Available out of the box" in this sentence means "part of standard >> library". > > Citation, please? I can find neither Mersenne nor "MT19937-64" anywhere > in n5001.pdf, the latest draft version of the C++ standard that I have > access to, which is dated 2024-12-17. N5001 29.5.4.3 [rand.eng.mers] "Class template mersenne_twister_engine". N5001 29.5.6 [rand.predef] "Engines and engine adaptors with predefined parameters" defines "mt19937" and "mt19937_64". Its description of the algorithm isn't very detailed, but it does impose some very specific requirements. For mt19937: "Required behavior: The 10000th consecutive invocation of a default-constructed object of type mt19937 produces the value 4123659995.". For mt19937_64: "Required behavior: The 10000th consecutive invocation of a default-constructed object of type mt19937_64 produces the value 9981545732273789042." If we're going to discuss this in any more detail (rather than discussing random numbers in general), I suggest comp.lang.c++. As already mentioned, there are implementations of mt19937 for C, but unlike in C++ they aren't part of the standard library. -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com void Void(void) { Void(); } /* The recursive call of the void */