Newsgroups: | comp.parallel,comp.arch,comp.compilers |
From: | "David B. Chorlian" <davidc@panix.com> |
Status: | R |
Originator: | rmuise@dragon.acadiau.ca |
Organization: | PANIX Public Access Internet and Unix, NYC |
References: | <3aqv5k$e27@monalisa.usc.edu> <3b015c$bt@rational.rational.com> |
Date: | Thu, 24 Nov 1994 22:49:37 GMT |
In <3b015c$bt@rational.rational.com> davidm@Rational.COM (David Moore) writes:
[snip]
>programmer can help by using a double temporary instead of floating i:
> double di=1.0;
> for(i=1;i<=N;i=i+1) {
> local = ( (di - 0.5 ) * w ;
> pi = pi + 4.0 / ( 1.0 + local * local ) ;
> di += 1.0;
> }
The above code verges on inaccuracy by keeping an index variable as
a floating point number and incrementing it by a floating point
number. Systematic error is introduced into such an index variable if the
increment quantity does not have an exact binary representation.
--
David B. Chorlian
Neurodynamics Lab SUNY/HSCB
chorlian@sp1p.neurodyn.hscbklyn.edu
davidc@panix.com
Return to the
comp.compilers page.
Search the
comp.compilers archives again.