3 ms·
User lispm points out that this was a design decision that's in the clisp documentation. I couldn't find the reference, but I did find that they also compute an
by ksaj 6y ago
User lispm points out that this was a design decision that's in the clisp documentation. I couldn't find the reference, but I did find that they also compute any "negative integer" as zero, so that might seem consistent at the least.
Mainly I pointed this out because OP was asking about how my programming language handles it. LispWorks, sbcl and clisp are technically all the same language, so there is no singular answer to that question when it comes to Common Lisp.
- lispm 6y ago12.2.4 https://clisp.sourceforge.io/impnotes.html#num-concepts https://clisp.sourceforge.io/impnotes.html#num-concepts and http://www.lispworks.com/documentation/HyperSpec/Body/t_float.htm http://www.lispworks.com/documentation/HyperSpec/Body/t_floa... > In addition, there is a floating-point zero; depending on the implementation, there can also be a ``minus zero''. If there is no minus zero, then 0.0 and -0.0 are both interpreted as simply a floating-point zero. (= 0.0 -0.0) is always true. If there is a minus zero, (eql -0.0 0.0) is false, otherwise it is true.
- ksaj 6y agoAsk, and ye shall receive. Thanks for the links.
- kazinator 6y agoHow the language handles it is that neither 0.0 nor -0.0 satisfy either the minusp or plusp function, and the numbers are equal under eql or weaker. I think the only way to write a comparison function f such that (f -0.0 0.0) yields nil would be to print the numbers into character strings and compare those. But even that wouldn't be portable to CLISP.
- ksaj 6y agoA rising zero / falling zero is the difference between freezing and melting, where you can see zero as a fuzzy number that is too low to consider close to 1, and too high to consider close to -1, while distinctly approaching one or the other. Here's a LispWorks session: CL-USER 1 > (minusp -0.0f0) ; as you said NIL CL-USER 2 > (< -0.f0 0.0f0) ; as minusp & you predict NIL CL-USER 3 > (* -0.f0 0.f0) ; but... -0.0 CL-USER 4 > It seems inconsistent that the multiply function understands that zero is approaching -1, but less-than doesn't.