commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gilles (JIRA)" <>
Subject [jira] [Commented] (MATH-1300) BitsStreamGenerator#nextBytes(byte[]) is wrong
Date Sat, 19 Dec 2015 23:30:46 GMT


Gilles commented on MATH-1300:

Personally, I'm always in favour of cleaining up in the sense to make the code safer and more
understandable, before trying to grab a few milliseconds in a micro-benchmark.
If we want to focus on performance, it would be better to have a realistic use-case (e.g.
estimate how much time is spent in "nextBytes" relative to the usage of the generated numbers).

I think that we need to determine how to resolve the original issue, and perhaps open another
report for the performance improvement.

> BitsStreamGenerator#nextBytes(byte[]) is wrong
> ----------------------------------------------
>                 Key: MATH-1300
>                 URL:
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.5
>            Reporter: Rostislav Krasny
>         Attachments:,
> Sequential calls to the BitsStreamGenerator#nextBytes(byte[]) must generate the same
sequence of bytes, no matter by chunks of which size it was divided. This is also how java.util.Random#nextBytes(byte[])
> When nextBytes(byte[]) is called with a bytes array of length multiple of 4 it makes
one unneeded call to next(int) method. This is wrong and produces an inconsistent behavior
of classes like MersenneTwister.
> I made a new implementation of the BitsStreamGenerator#nextBytes(byte[]) see attached

This message was sent by Atlassian JIRA

View raw message