Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

subtypep with float ranges

17 views
Skip to first unread message

Jim Newton

unread,
Mar 16, 2018, 10:52:17 AM3/16/18
to
Can anyone explain to me what (subtypep '(float 0.0 0.0) '(eql 0.0)) should evaluate to?
In SBCL it evaluates to NIL,T which seems bizarre to me.

Sam Steingold

unread,
Mar 16, 2018, 1:18:10 PM3/16/18
to
> * Jim Newton <wvzxn...@tznvy.pbz> [2018-03-16 07:52:11 -0700]:
>
> Can anyone explain to me what (subtypep '(float 0.0 0.0) '(eql 0.0))
> should evaluate to?
> In SBCL it evaluates to NIL,T which seems bizarre to me.

Seems legit, you are forgetting that (eql 0.0 0.0s0) is NIL:

--8<---------------cut here---------------start------------->8---
[1]> (subtypep '(float 0.0 0.0) '(eql 0.0))
NIL ;
T
[2]> (typep 0.0s0 '(float 0.0 0.0))
T
[3]> (typep 0.0s0 '(eql 0.0))
NIL
--8<---------------cut here---------------end--------------->8---

Thanks.

--
Sam Steingold (http://sds.podval.org/) on darwin Ns 10.3.1561
http://steingoldpsychology.com http://www.childpsy.net http://no2bds.org
http://camera.org http://www.dhimmitude.org http://jij.org
If a train station is a place where a train stops, what's a workstation?

tar...@google.com

unread,
Mar 16, 2018, 2:33:39 PM3/16/18
to
On Friday, March 16, 2018 at 10:18:10 AM UTC-7, sds wrote:
> > * Jim Newton <wvzxn...@tznvy.pbz> [2018-03-16 07:52:11 -0700]:
> >
> > Can anyone explain to me what (subtypep '(float 0.0 0.0) '(eql 0.0))
> > should evaluate to?
> > In SBCL it evaluates to NIL,T which seems bizarre to me.
>
> Seems legit, you are forgetting that (eql 0.0 0.0s0) is NIL:

That depends on what the default float type is.
In my SBCL (eql 0.0 0.0s0) => T whereas (eql 0.0 0.0d0) => NIL.

>
> --8<---------------cut here---------------start------------->8---
> [1]> (subtypep '(float 0.0 0.0) '(eql 0.0))
> NIL ;
> T
> [2]> (typep 0.0s0 '(float 0.0 0.0))
> T

But also
(typep 0.0d0 '(float 0.0 0.0)) => T
(typep 0.0s0 '(float 0.0d0 0.0d0)) => T as well

> [3]> (typep 0.0s0 '(eql 0.0))

Depends on the setting of *READ-DEFAULT-FLOAT-FORMAT* and how many types of
floats are supported in your lisp implementation.

> NIL
> --8<---------------cut here---------------end--------------->8---

The EQL type descriptor is narrower since it requires type equivalence, which will make it potentially implementation-dependent. And since the FLOAT type
specifier will do type conversions, it is a supertype:

(subtypep '(eql 0.0) '(float 0.0 0.0)) => T T
0 new messages