home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c      Meh, in C you gotta define EVERYTHING      243,242 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 242,884 of 243,242   
   Michael S to Tim Rentsch   
   Re: srand(0)   
   07 Jan 26 18:14:14   
   
   From: already5chosen@yahoo.com   
      
   On Wed, 07 Jan 2026 07:46:40 -0800   
   Tim Rentsch  wrote:   
      
   > Michael S  writes:   
   >   
   > [regarding rand() and srand()]   
   >   
   > > Pay attention that C Standard only requires for the same seed to   
   > > always produces the same sequence.  There is no requirement that   
   > > different seeds have to produce different sequences.   
   > > So, for generator in your example, implementation like below would   
   > > be fully legal.  Personally, I wouldn't even consider it as   
   > > particularly poor quality:   
   > >   
   > > void srand(unsigned seed ) { init = seed | 1;}   
   >   
   > It seems better to do, for example,   
   >   
   >   void srand(unsigned seed ) { init = seed - !seed;}   
   >   
      
   Yes, it is better.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca