You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's not explicitly specified what the absolute value of -0.0 is, if -0.0 exists. There is an example:
(eql (abs -0.0) -0.0) => true
But examples are not normative, and this disagrees with standard practice (checked sbcl, ccl, abcl, ecl; clisp has no -0.0). Presumably, the intent of the standard was that -0.0 and 0.0 are both valid results for the absolute value. I suggest to say that (abs -0.0) must always be a positive zero, because:
agrees with ieee 754
agrees with standard practice
agrees with float-sign
under the limit interpretation of signed zeroes, it is the more useful result
It does break the invariant that (not (minusp x)) implies (eql x (abs x)). (Or, put another way, it eliminates (if (< x 0) (- x) x) as a potential implementation of abs for reals.) But signed zero already breaks the putative invariant that, if two numbers are = and they have the same type, then they are eql, so that does not seem like too big of a deal.
The text was updated successfully, but these errors were encountered:
It's not explicitly specified what the absolute value of -0.0 is, if -0.0 exists. There is an example:
But examples are not normative, and this disagrees with standard practice (checked sbcl, ccl, abcl, ecl; clisp has no -0.0). Presumably, the intent of the standard was that -0.0 and 0.0 are both valid results for the absolute value. I suggest to say that (abs -0.0) must always be a positive zero, because:
It does break the invariant that (not (minusp x)) implies (eql x (abs x)). (Or, put another way, it eliminates (if (< x 0) (- x) x) as a potential implementation of abs for reals.) But signed zero already breaks the putative invariant that, if two numbers are = and they have the same type, then they are eql, so that does not seem like too big of a deal.
The text was updated successfully, but these errors were encountered: