Notices
Results 1 to 2 of 2

Thread: Random power

  1. #1 Random power 
    Forum Freshman
    Join Date
    Nov 2013
    Posts
    11
    Hey, I'm still learning English. I have studied and done the math, and 30 years.
    I will present all of the results, as I learned better English. Here are random power.

    Code:
    #include <stdio.h>
    
    unsigned rnd(unsigned max)
    {
       static unsigned R16A=1L;
       static unsigned R16B=2L;
       R16A -= 0x012357bfL;
       R16B += 0xfedca201L;
       R16A += (R16A>>16)^(R16B<<16);
       R16B -= (R16A<<16)^(R16B>>16);
       return (R16A^R16B)%max;
    }
    
    void main(void)
    {
       for (;;)
       {
          printf("%20d", rnd(0x7fffffff));
       }
    }


    Reply With Quote  
     

  2.  
     

  3. #2  
    Forum Radioactive Isotope MagiMaster's Avatar
    Join Date
    Jul 2006
    Posts
    3,440
    Diehard tests - Wikipedia, the free encyclopedia

    BTW, you probably want to move those two variables outside the function so you can make a separate seed function so you don't get the same sequence every time you run the program.


    Reply With Quote  
     

Similar Threads

  1. Solar power, distributed power, This is terrific news
    By adelady in forum Environmental Issues
    Replies: 3
    Last Post: December 20th, 2012, 01:45 AM
  2. Replies: 9
    Last Post: November 12th, 2008, 11:13 AM
Bookmarks
Bookmarks
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •