Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(abs -0.0) #33

Open
moon-chilled opened this issue Aug 20, 2023 · 0 comments
Open

(abs -0.0) #33

moon-chilled opened this issue Aug 20, 2023 · 0 comments

Comments

@moon-chilled
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant