home bbs files messages ]

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

   comp.compilers      Compiler construction, theory, etc. (Mod      2,753 messages   

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

   Message 1,840 of 2,753   
   glen herrmannsfeldt to Ray   
   Re: Executing code at compilation time   
   23 Mar 10 03:26:27   
   
   From: gah@ugcs.caltech.edu   
      
   Ray  wrote:   
   (snip)   
      
   > Yes, John got it right.  If we have C code which says,   
      
   > double addend = 0.5;   
   > double sum = 0.0;   
   > while (1){   
   >   sum += addend;   
   >   addend *= 0.5;   
   > }   
      
   > Then the programmer is a maniac.   
      
   OK, but how about:   
      
    double addend = 0.5;   
    double sum = 0.0;   
    while (addend){   
      sum += addend;   
      addend *= 0.5;   
    }   
      
   -- glen   
   [The traditional Fortran rules say that any transformation that's   
   mathematically valid is OK,   
   even if it's not numerically identical.  So translate it to this:   
      
         DOUBLE PRECISION ADDEND, SUM   
         ADDEND = 0.5   
         SUM = 0.0   
   10    IF(ADDEND)20,30,20   
   20    SUM = SUM + ADDEND   
         ADDEND = ADDEND * 5E-1   
         GOTO 10   
   30    CONTINUE   
         STOP   
         END   
      
   -John]   
      
   --- 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