You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ah...@apache.org on 2021/06/14 16:09:07 UTC

[commons-rng] branch master updated: Shift the bits for the descending sequence.

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


The following commit(s) were added to refs/heads/master by this push:
     new 31def23  Shift the bits for the descending sequence.
31def23 is described below

commit 31def23537c2f3974e9c448225931479c21acfe2
Author: aherbert <ah...@apache.org>
AuthorDate: Mon Jun 14 17:09:03 2021 +0100

    Shift the bits for the descending sequence.
---
 .../sampling/distribution/ContinuousUniformSamplerTest.java    | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/ContinuousUniformSamplerTest.java b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/ContinuousUniformSamplerTest.java
index f1cf6f9..74f86ea 100644
--- a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/ContinuousUniformSamplerTest.java
+++ b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/ContinuousUniformSamplerTest.java
@@ -63,16 +63,18 @@ public class ContinuousUniformSamplerTest {
             private long l2;
             @Override
             public long nextLong() {
+                long x;
                 if (l1 > l2) {
                     l2++;
                     // Descending sequence: -1, -2, -3, ...
-                    return -l2;
+                    x = -l2;
+                } else {
+                    // Ascending sequence: 0, 1, 2, ...
+                    x = l1++;
                 }
-                // Ascending sequence: 0, 1, 2, ...
-                l1++;
                 // Shift by 11 bits to reverse the shift performed when computing the next
                 // double from a long.
-                return l1 << 11;
+                return x << 11;
             }
         };
         final double low = 3.18;