You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gilles (JIRA)" <ji...@apache.org> on 2016/02/09 14:46:18 UTC
[jira] [Commented] (MATH-1322) Negative integer seed for
MersenneTwister is not working.
[ https://issues.apache.org/jira/browse/MATH-1322?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15138953#comment-15138953 ]
Gilles commented on MATH-1322:
------------------------------
bq. If seed is negative, longMT also becomes negative.
I'd rather expect that both types result in the same value.
Why is it a problem?
The documentation does not seem to imply any constraint on the argument.
Do I understand correctly that if your patch were applied, each of the following calls would result in the generator being in a different state:
{code}
rng.setSeed(-1);
rng.setSeed((long) -1);
{code}
?
> Negative integer seed for MersenneTwister is not working.
> ---------------------------------------------------------
>
> Key: MATH-1322
> URL: https://issues.apache.org/jira/browse/MATH-1322
> Project: Commons Math
> Issue Type: Bug
> Affects Versions: 3.6
> Reporter: Morikawa Joe
> Labels: patch
> Attachments: MersenneTwister.patch
>
>
> MersenneTwister.setSeed(int seed) has a bug.
> If seed is negative, longMT also becomes negative.
> First 32 bits are filled by 0xFFFFFFFF.
> But it should be positive. First 32 bits should be filled by 0x00000000.
> Ex) Integer -1 is 0xffffffff.
> Long -1 is 0xffffffffffffffff.
> Long 0xffffffff is 4294967295.
> I created simple patch.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)