Date: Wed, 16 Nov 1994 10:51:32 +1100 From: Bill Metzenthen Subject: Re: Paranoia To: UCKO AT VAX1 DOT ROCKHURST DOT EDU Cc: djgpp AT sun DOT soe DOT clarkson DOT edu Aaron Ucko (ucko AT vax1 DOT rockhurst DOT edu) wrote: > >'paranoia' should never be compiled with optimizations. > > Really? It doesn't warn against them, and optimized TC++ got a perfect score. > But I guess TC++ doesn't exactly "optimize." :-) paranoia doesn't really guard against the efforts of an optimizer. In principle, a sufficiently smart optimizer could reduce the program to little more than a series of printf() statements. It need make almost no use of the FPU at run time! (this property is the reason behind another class of "gcc is broken" messages to the net...). > >As I said, 'paranoia' incorrectly reports one FLAW. The 80x87 FPUs do > >correctly round/truncate (unless you are unfortunate enough to have a > >faulty chip ;-). You will probably get this incorrect FLAW reported > >with any modern 'C' compiler (i.e. one which supports long doubles) > >and an 80x86 machine (where the normal convention with 80x87 FPUs is > >to use the 53 bit precision type as a double, and the 64 bit precision > >type as a long double). > > Really? And why would that be? It comments on there being the 11 extra > digits of precision, but wouldn't that, if anything, improve accuracy?? It > certainly doesn't have a problem with the 40 extra bits in single-precision > mode. Two points here: (1) The comment in the output from 'paranoia': Some subexpressions appear to be calculated extra precisely with about 11 extra B-digits, i.e. roughly 3.31133 extra significant decimals. That feature is not tested further by this program. ^^^ ^^^^^^ ^^^^^^^ The author should have made this stronger, it should say something like: That feature is not taken into account by this program. (2) If you look at the section of paranoia which deals with rounding, etc (not easy, the author didn't seem to care much about readability), you will see that the code will work only if the precision of the extra precise stuff is at least twice the nominal precision (or, trivially, if there is no extra precise stuff). This is a fundamental feature of floating point numbers. Hence 'doubles' give problems (64 < 2*53), but 'floats' work o.k. (64 >= 2*23). Indeed 'floats' would always work o.k. with paranoia, no matter how you set the 80x87 FPU precision. --Bill