public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "spoon.reloaded at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/51795] linear_congruential_engine doesn't work correctly Date: Fri, 27 Jan 2012 21:45:00 -0000 [thread overview] Message-ID: <bug-51795-4-slZgpR1IMM@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-51795-4@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51795 --- Comment #19 from spoon.reloaded at gmail dot com 2012-01-27 21:21:40 UTC --- Paulo, in response to your suggestion to simply do multiplication and modulo in #7 and #8, I don't think that would work in general. The example I gave happened to have m = a power of 2 (namely 2^31), and so the truncation that we would get from integer overflow (whether by 2^32 if we use uint32_t or 2^64 if we use uint64_t) does not affect the result. However, if we choose any other number as a modulo (e.g. 2^31 - 1) and say we use uint32_t as the type, it will not work: (1103515245 * 1103527590 + 12345) % 2147483647 = 944465040 but in uint32_t arithmetic: (1103515245 * 1103527590 + 12345) % (1 << 32) % 2147483647 = 377401576 This is why I think we still need something like the Schrage's algorithm
next prev parent reply other threads:[~2012-01-27 21:22 UTC|newest] Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-01-09 6:09 [Bug libstdc++/51795] New: " spoon.reloaded at gmail dot com 2012-01-27 7:01 ` [Bug libstdc++/51795] " 3dw4rd at verizon dot net 2012-01-27 10:59 ` paolo.carlini at oracle dot com 2012-01-27 11:23 ` paolo.carlini at oracle dot com 2012-01-27 11:46 ` paolo.carlini at oracle dot com 2012-01-27 12:18 ` paolo.carlini at oracle dot com 2012-01-27 12:47 ` paolo.carlini at oracle dot com 2012-01-27 12:53 ` paolo.carlini at oracle dot com 2012-01-27 13:02 ` paolo.carlini at oracle dot com 2012-01-27 13:06 ` marc.glisse at normalesup dot org 2012-01-27 13:07 ` paolo.carlini at oracle dot com 2012-01-27 13:42 ` marc.glisse at normalesup dot org 2012-01-27 13:48 ` paolo.carlini at oracle dot com 2012-01-27 13:49 ` paolo.carlini at oracle dot com 2012-01-27 13:55 ` marc.glisse at normalesup dot org 2012-01-27 13:58 ` paolo.carlini at oracle dot com 2012-01-27 14:08 ` paolo.carlini at oracle dot com 2012-01-27 14:12 ` marc.glisse at normalesup dot org 2012-01-27 14:28 ` paolo.carlini at oracle dot com 2012-01-27 21:45 ` spoon.reloaded at gmail dot com [this message] 2012-01-27 21:50 ` spoon.reloaded at gmail dot com 2012-01-27 21:51 ` paolo.carlini at oracle dot com 2012-01-27 21:53 ` paolo.carlini at oracle dot com 2012-01-27 21:56 ` spoon.reloaded at gmail dot com 2012-01-27 22:32 ` paolo.carlini at oracle dot com 2012-01-27 23:08 ` marc.glisse at normalesup dot org 2012-01-28 0:34 ` paolo at gcc dot gnu.org 2012-01-28 11:34 ` paolo.carlini at oracle dot com 2012-01-30 16:26 ` paolo.carlini at oracle dot com 2012-02-01 11:12 ` paolo at gcc dot gnu.org 2012-04-29 23:37 ` paolo at gcc dot gnu.org 2012-04-29 23:39 ` paolo.carlini at oracle dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-51795-4-slZgpR1IMM@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).