Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Period

  1. #1
    Junior Member
    Join Date
    Mar 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Period

    One of the random number generators in Java extract the higher-order bits of the random number in order to get a longer period.

    I'm not sure if I understand how this is done. Suppose that the random number r = 0000 1100 1000 1101. If we extract the 16 most significant bits from r; is the new number r = 0000 1100 or r = 0000 1100 0000 0000?


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Period

    One of the random number generators in Java
    Can you specify which random number generator you're talking about and provide a reference for the functional description you've given?

  3. #3
    Junior Member
    Join Date
    Mar 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Period

    From Linear congruential generator - Wikipedia, the free encyclopedia
    As shown above, LCGs do not always use all of the bits in the values they produce. For example, the Java implementation operates with 48-bit values at each iteration but returns only their 32 most significant bits. This is because the higher-order bits have longer periods than the lower-order bits (see below). LCGs that use this truncation technique produce statistically better values than those that do not.

    java.util.Random

  4. #4
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Period

    You might find the Random source code helpful. Maybe not.

Similar Threads

  1. function to get the number of a .(period)
    By gvs048 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 14th, 2013, 06:42 AM
  2. execute a method over a maximum period of time
    By PedroCosta in forum What's Wrong With My Code?
    Replies: 5
    Last Post: August 24th, 2011, 02:06 PM
  3. Remove from array after a period of time
    By Marty in forum Collections and Generics
    Replies: 1
    Last Post: September 1st, 2009, 07:57 AM