Share your knowledge at the LQ Wiki.
 Home Forums HCL Reviews Tutorials Articles Register Search Today's Posts Mark Forums Read
 LinuxQuestions.org Super period
 User Name Remember Me? Password
 Programming This forum is for all programming questions. The question does not have to be directly related to Linux and any language is fair game.

Notices

 03-01-2014, 07:43 AM #1 l0p3n LQ Newbie   Registered: Jul 2013 Distribution: Debian Posts: 14 Rep: Super period http://en.wikipedia.org/wiki/Linear_..._in_common_use 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? Last edited by l0p3n; 03-01-2014 at 07:53 AM.
 03-03-2014, 08:38 PM #2 ntubski Senior Member   Registered: Nov 2005 Distribution: Debian Posts: 2,654 Rep: You have your bit counts a bit mixed up. Code: ```A 48 bit random number, the internal value Xn 0011 0111 0000 1010 0111 1101 1001 0000 0111 1101 1110 1011 32 high bits, what is returned from Math.random() 0011 0111 0000 1010 0111 1101 1001 0000``` Note that the lower 16 bits are not thrown away, they just aren't given to the application (caller of random()).
 03-04-2014, 12:47 AM #3 l0p3n LQ Newbie   Registered: Jul 2013 Distribution: Debian Posts: 14 Original Poster Rep: If I have understood this correctly the 48 bits will be saved and used when generating the next random number. But what is returned as the random number to the calling application are the 32 higher-order bits of the generated number? Last edited by l0p3n; 03-04-2014 at 12:57 AM.

 Thread Tools Search this Thread Search this Thread: Advanced Search

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is Off HTML code is Off Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post LinuxInDepth Red Hat 1 04-29-2012 06:24 PM asmahan Linux - Software 2 08-24-2009 01:40 PM newbiesforever Linux - Software 5 05-22-2009 02:04 PM vkmgeek Programming 3 09-02-2008 09:41 AM Steve_Taylor Programming 12 09-30-2001 04:21 PM

All times are GMT -5. The time now is 11:50 AM.

 Contact Us - Advertising Info - Rules - LQ Merchandise - Donations - Contributing Member - LQ Sitemap -
 Advertisement
 My LQ
 Write for LQ LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
 Syndicate Latest Threads   LQ News Twitter: @linuxquestions Facebook: linuxquestions Google+: linuxquestions