Received: from mailsec118.isp.belgacom.be (mailsec118.isp.belgacom.be [195.238.20.114]) by mail-b.sr.ht (Postfix) with ESMTPS id BE8E8FF112 for <~skeeto/public-inbox@lists.sr.ht>; Wed, 18 Nov 2020 14:47:55 +0000 (UTC) Authentication-Results: mail-b.sr.ht; dkim=pass (1024-bit key) header.d=skynet.be header.i=@skynet.be header.b=DGeWFVkk DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=skynet.be; i=@skynet.be; q=dns/txt; s=rmail; t=1605710875; x=1637246875; h=date:from:to:subject:message-id:mime-version: content-transfer-encoding; bh=sEjZf/H8ylgafFefIE8M2pZSloEEfEUsMC2jDhqk2zA=; b=DGeWFVkkfBZf7CnJk5KIF7Ds1h/EZo0Am5Pj/pE4NKMrQryMudzm3VFE gDQL0aZX08KY3GjcuCgoU1EhvjcLRDRH5xNZ69dMC9+svwSf+C3w8m3lE /7GdBVWrez6iVFPJ8tPafuOXmPX4GWxMAJyrX5bHzzNkqBIA36UQtHsgJ s=; IronPort-SDR: hkYErondsKWzCIuegJv6sfni7yFSXoZXITT24s4FaCpj0CjPUlajbsxhCWDUQxRUThkMIpEoWn kzUGN3F59x/APpopTY2/O1FeyWHpzPwAPQHfjBpCGoTU0uJGSNg3vyg5qRhvPHknJpOWtO/uHv xrXOX7km3OjS/NdyfONz8xrDTqDh6ySP6bn12dj7EV+IOFv8V4PZgFvDSgspKANn8KGYFcWTfZ DrXNIX12QeXjIePtlL65kL2D3hlNKZGNxr1YuPeHmprA2ut4BJjlu7Kc0vU0IPGOxLQ6Z10luU QMs= IronPort-PHdr: =?us-ascii?q?9a23=3AjvyAJRV47uTBt2rVIcN792DqyXLV8LGtZVwlr6?= =?us-ascii?q?E/grcLSJyIuqrYbBeDt8tkgFKBZ4jH8fUM07OQ7/m/HzVbvN3f4TgrS99lb1?= =?us-ascii?q?c9k8IYnggtUoauKHbQC7rUVRE8B9lIT1R//nu2YgB/Ecf6YEDO8DXptWZBUh?= =?us-ascii?q?rwO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0?= =?us-ascii?q?SSJHvqiNAROWMLpRYlCvfwzl2eAhBJYHPndKIm5yonD5qmAM/4Wokqjaea0W?= =?us-ascii?q?/vFZ1ffXxPC3iXEmbuepnCUfpaO3HaGdNojjFRDevpcIQmzxz77AI=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A2DSBADLMrVf/9aY81FiHgEBCxIMQAe?= =?us-ascii?q?DQ4F4jiOGDJ5ECwEBAQEBAQEBAQksAQIEAQGGciY4EwIDAQEBAwIFAQEGAQE?= =?us-ascii?q?BAQEBBQQBhhhFgjcigxsEOxwoSocPJK9igTSFV4RrgTiFWRI8hzSCAIlshSk?= =?us-ascii?q?EkEyLe4pOkSCCdwSICodnixUPIqF6r3SEXoFrgXptGIMlTxkNjisXgQIBCI0?= =?us-ascii?q?cQ2cCBgoBAQMJRAEBEQEiAY1NAQE?= X-IPAS-Result: =?us-ascii?q?A2DSBADLMrVf/9aY81FiHgEBCxIMQAeDQ4F4jiOGDJ5EC?= =?us-ascii?q?wEBAQEBAQEBAQksAQIEAQGGciY4EwIDAQEBAwIFAQEGAQEBAQEBBQQBhhhFg?= =?us-ascii?q?jcigxsEOxwoSocPJK9igTSFV4RrgTiFWRI8hzSCAIlshSkEkEyLe4pOkSCCd?= =?us-ascii?q?wSICodnixUPIqF6r3SEXoFrgXptGIMlTxkNjisXgQIBCI0cQ2cCBgoBAQMJR?= =?us-ascii?q?AEBEQEiAY1NAQE?= Received: from 214.152-243-81.adsl-dyn.isp.belgacom.be (HELO asus.home) ([81.243.152.214]) by relay.proximus.be with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Nov 2020 15:47:52 +0100 Date: Wed, 18 Nov 2020 15:47:52 +0100 From: Christophe =?ISO-8859-1?Q?Sta=EFesse?= To: ~skeeto/public-inbox@lists.sr.ht Subject: Improving on QBasic's Random Number Generator Message-Id: <20201118154752.5854d027b288acf1a685f298@skynet.be> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Hello, Interesting article! > the implementation is a full 32-bit multiply using 16-bit limbs > (note: the LCG constants listed here are wrong) It is actually a 24-bit multiplier (a hint is that there are 3 multiplications) ant it computes: word[RndVar]*word[RndA] + 65536*word[RndVar+2]*word[RndA] + 65536*word[RndA]*word[RndVar] The third multiplication is identical to the first. This is a bug. word[RndA] should actually be word[RndA+2]. This is why a=0xfd43fd and not 0x343fd as documented. There is another bug similar in the addition of c: ... + word[RndC] + 65536*byte[RndC]. byte[RndC] should be byte[RndC+2]. Hence c=0xc39ec3 instead of 0x269ec3. I checked the original code and RandA and RandC are defined as 32-bit variables initialised with the documented constants. That said, even the fixed version produces a similarly bad randogram and a quick check seems to confirm that removing the lowest-order byte produces better result. Cheers, Christophe.