[Python-Dev] stupid floating point question...

Martin von Loewis loewis@informatik.hu-berlin.de
Thu, 28 Sep 2000 17:37:10 +0200 (MET DST)

> A *good* compiler won't collapse *any* fp expressions at
> compile-time, because doing so can change the 754 semantics at
> runtime (for example, the evaluation of 1./6 triggers the 754
> "inexact" signal, and the compiler has no way to know whether the
> user is expecting that to happen at runtime, so a good compiler will
> leave it alone

Of course, that doesn't say anything about what *most* compilers do.
For example, gcc, on i586-pc-linux-gnu, compiles

double foo(){
	return (double)1/6;


	.long 0x55555555,0x3fc55555
	.align 4
.globl foo
	.type	 foo,@function
	fldl .LC0

when compiling with -fomit-frame-pointer -O2. That still doesn't say
anything about what most compilers do - if there is interest, we could
perform a comparative study on the subject :-)

The "would break 754" argument is pretty weak, IMO - gcc, for example,
doesn't claim to comply to that standard.