lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Wed, 1 Dec 2010, jgiors@threeeyessoftware.com wrote:
>
> For me, there is just one mathematical zero, and its negation is equal
> to itself. But IEEE 754 has both +0 and -0, and in all contexts I've
> been exposed to, both are "exactly zero" to me (and as Luiz points out
> in another reply, IEEE 754 requires they compare equal).

The reason they are distinguished is to do with branch cuts, which are
especially important in complex arithmetic. See for example atan2() which
as well aas being useful in real geometry gives you the argument (polar
angle) of a complex number. For atan2(y,-1) the result is +pi if y == +0
and -pi if y == -0.

Tony.
-- 
f.anthony.n.finch  <dot@dotat.at>  http://dotat.at/
HUMBER THAMES DOVER WIGHT PORTLAND: NORTH BACKING WEST OR NORTHWEST, 5 TO 7,
DECREASING 4 OR 5, OCCASIONALLY 6 LATER IN HUMBER AND THAMES. MODERATE OR
ROUGH. RAIN THEN FAIR. GOOD.