On 06/06/2019 16:07, Gilles Sadowski wrote:
Hi.

Not sure about the changes below.
It seems to me that "nextLong()" ensures that a "long" is generated,
while "next()" could, if the RNG type is later changed, return an "int"
cast to "long" (i.e. half its bits set to zero).

Regards,
Gilles

Good spot. It was introduced when looking at a weird performance spike in the JMH timings for seed conversion. I do not think it was the problem and could be a bigger, different problem in the future.

I will fix this with a revert.


Le jeu. 6 juin 2019 à 10:00, <aherb...@apache.org> a écrit :
This is an automated email from the ASF dual-hosted git repository.

aherbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-rng.git

commit aa246979feb8c880c60c972faf7c9ffb9174f4cd
Author: Alex Herbert <aherb...@apache.org>
AuthorDate: Fri May 31 22:35:25 2019 +0100

     RNG-75: Use SplitMix64.next()
---
  .../java/org/apache/commons/rng/simple/internal/Long2IntArray.java    | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/commons-rng-simple/src/main/java/org/apache/commons/rng/simple/internal/Long2IntArray.java
 
b/commons-rng-simple/src/main/java/org/apache/commons/rng/simple/internal/Long2IntArray.java
index d98a77c..2f7660c 100644
--- 
a/commons-rng-simple/src/main/java/org/apache/commons/rng/simple/internal/Long2IntArray.java
+++ 
b/commons-rng-simple/src/main/java/org/apache/commons/rng/simple/internal/Long2IntArray.java
@@ -62,11 +62,11 @@ public class Long2IntArray implements 
Seed2ArrayConverter<Long, int[]> {
          int i = 0;
          // Handle an odd size
          if ((size & 1) == 1) {
-            out[i++] = NumberFactory.extractHi(rng.nextLong());
+            out[i++] = NumberFactory.extractHi(rng.next());
          }
          // Fill the remaining pairs
          while (i < size) {
-            final long v = rng.nextLong();
+            final long v = rng.next();
              out[i] = NumberFactory.extractHi(v);
              out[i + 1] = NumberFactory.extractLo(v);
              i += 2;

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to