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,526 of 243,242   
   Janis Papanagnou to Kaz Kylheku   
   Re: srand(0)   
   22 Dec 25 22:35:35   
   
   From: janis_papanagnou+ng@hotmail.com   
      
   On 2025-12-22 20:16, Kaz Kylheku wrote:   
   > On 2025-12-22, Janis Papanagnou  wrote:   
      
   [...]   
      
   > I don't recall having paid attention to this exact material in the   
   > past so it is a "TIL" for me.   
      
   What does "TIL" mean?   
      
   I actually had used PN-generators in the past; used it in a Pascal   
   program to make statistical tests, and also in assembler for a DSP   
   codec to create reproducible random payload data to compare after   
   transmission. For that purpose it was the perfect choice.   
      
   >   
   >> #include    
   >>   
   >> int main ()   
   >> {   
   >>       uint32_t init = 0x00000038;   
   >>       uint32_t reg = init;   
   >>       uint32_t new_bit;   
   >>       int count = 0;   
   >>       do {   
   >>           new_bit = ((reg >> 2) + (reg >> 4) + (reg >> 6) + (reg >> 30))   
   >> & 0x1;   
   >   
   > These could of course be XOR, without it making a difference; the least   
   > significant bit in a binary addition is the XOR of the LSB's of the   
   > inputs.   
      
   Actually the pluses are a remnant of my decades old piece of Pascal   
   code that I wrote back then that I now just transcribed. The Pascal   
   version I used back then didn't support XOR so I used the addition.   
   Being in a boolean context I'd nowadays (in C) have rather written   
   purely  new_bit = ((reg>>2)^(reg>>4)^(reg>>6)^(reg>>30)) & 0x1;   
   but since it's unimportant, as you say, I lazily left it as it was.   
      
   Janis   
      
   > [...]   
      
   --- 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