Related articles |
---|
[12 earlier articles] |
Re: Executing code at compilation time gah@ugcs.caltech.edu (glen herrmannsfeldt) (2010-03-17) |
Re: Executing code at compilation time bear@sonic.net (Ray) (2010-03-19) |
Re: Executing code at compilation time bear@sonic.net (Ray) (2010-03-19) |
Re: Executing code at compilation time bobduff@shell01.TheWorld.com (Robert A Duff) (2010-03-21) |
Re: Executing code at compilation time torbenm@diku.dk (2010-03-22) |
Re: Executing code at compilation time bear@sonic.net (Ray) (2010-03-22) |
Re: Executing code at compilation time gah@ugcs.caltech.edu (glen herrmannsfeldt) (2010-03-23) |
Re: Executing code at compilation time martin@gkc.org.uk (Martin Ward) (2010-03-26) |
From: | glen herrmannsfeldt <gah@ugcs.caltech.edu> |
Newsgroups: | comp.compilers |
Date: | Tue, 23 Mar 2010 03:26:27 +0000 (UTC) |
Organization: | California Institute of Technology, Pasadena |
References: | 10-03-038 10-03-050 10-03-056 10-03-065 10-03-076 |
Keywords: | optimize |
Posted-Date: | 23 Mar 2010 23:50:56 EDT |
Ray <bear@sonic.net> 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]
Return to the
comp.compilers page.
Search the
comp.compilers archives again.