Re: [dev] dwm-5.6

From: sqweek <>
Date: Tue, 21 Jul 2009 02:38:03 +0800

2009/7/18 Szabolcs Nagy <>:
> my problem was that it seems that c and ieee754 does not even require
> that the arithmetic operations are well defined: same operation on
> same numbers with same type does not necessary give the same result
> (even on same architecture with same compiler)
> for example
> (double)atoi("1")/atoi("3") == (double)atoi("1")/atoi("3")
> gives false with gcc on my x86 machine eventhough the two expressions
> are semantically equivalent

 Interesting indeed, I get the same result here. However, if you store
the division results in variables[1] you do get equality... strange.
Maybe related to the 80-bit floating point format used internally on
the cpu?
 I wonder if this is a gcc bug - the above expression gives me true in
the plan 9 compilers. Longstanding one though, I see it in gcc 3.3.6,
3.4.6 and 4.3.2 (ie, every compiler on my system).

[1] like so:
double d1 = (double)atoi("1")/atoi("3);
double d2 = (double)atoi("1")/atoi("3);
d1 == d2; /* true */

Received on Mon Jul 20 2009 - 18:38:03 UTC

This archive was generated by hypermail 2.2.0 : Mon Jul 20 2009 - 18:48:01 UTC