Uploaded image for project: 'Commons Math'
  1. Commons Math
  2. MATH-1300

BitsStreamGenerator#nextBytes(byte[]) is wrong

Rank to TopRank to BottomVotersWatch issueWatchersConvert to sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.5
    • Fix Version/s: 3.6
    • Labels:
      None
    • Flags:
      Patch, Important

      Description

      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[]) works.

      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 code.

        Attachments

        1. MersenneTwister2.java
          0.8 kB
          Rostislav Krasny
        2. TestMersenneTwister.java
          0.8 kB
          Rostislav Krasny

        Issue Links

          Activity

          $i18n.getText('security.level.explanation', $currentSelection) Viewable by All Users
          Cancel

            People

            • Assignee:
              Unassigned
              Reporter:
              rosti.bsd Rostislav Krasny

              Dates

              • Created:
                Updated:
                Resolved:

                Issue deployment