IEEE-754 abs and sign

20 Jan
2011
20 Jan
'11
9:45 a.m.
Hi, should the following hold? abs (-0.0) = 0.0 sign (-0.0) = -0.0 The generic definitions for abs and signum in ghc produce: Prelude> abs (-0.0) :: Float -0.0 Prelude> signum (-0.0) :: Float 0.0 The outcome for "abs (-0.0)" looks irritating. I know it does not matter for comparisons and the documented properties hold: <cite> The functions abs and signum should satisfy the law: abs x * signum x == x For real numbers, the signum is either -1 (negative), 0 (zero) or 1 (positive). </cite> Yet, I think, for numbers with a negative zero (class RealFloat) the top two equations above should hold. Cheers Christian
5282
Age (days ago)
5282
Last active (days ago)
0 comments
1 participants
participants (1)
-
Christian Maeder