Shachar Shemesh <[EMAIL PROTECTED]> writes:

> Actually, something extremely weird it going on here. The result
> change, considerably, when I compile with or without "no-math-errno":

<snip>

> > [EMAIL PROTECTED]:/tmp$ gcc -O2 -fno-math-errno -o test -lm test.c && time 
> > ./test
> > nan
> >
> > real    0m7.521s
> > user    0m7.517s
> > sys     0m0.003s
> 
> Why did the answer turn into "nan"?
> 
>        Shachar

Because when you mix no-math-errno with optimization you may break the
proper IEEE spec for math functions. It's right there in gcc docs. The
more common case is when you switch fast-math on (which is
no-math-errno and a few other options bundled together).

Don't ask me why the options exist: I will say that all errors should
be checked. I suspect that there are architectures (Motorolas) that
have lots of special math functions, including sqrt, sin, cos, etc
implemented as single instructions, and the fast-math options exist
for those.

-- 
Oleg Goldshmidt | [EMAIL PROTECTED] | http://www.goldshmidt.org

=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to