Hello,

I am fooling around IEEE 754 (don't ask why) and I started asking questions to various CL impleentations about the usual corner cases.  Take for example the function ACOS.

prompt> (acos 42.0)
#C(0.0 4.430675)


Seems legit, according to CLHS.  Now, suppose you do (e.g. in CCL)

CCL prompt> (acos 1D++0) ; 1D++0 is positive infinity
Error: FLOATING-POINT-INVALID-OPERATION detected
performing * on (0.0D0 1D++0)
While executing: CCL::%DOUBLE-FLOAT*-2!, in process Listener(4).
Type cmd-. to abort, cmd-\ for a list of available restarts.
Type :? for other options.
1 >

SBCL prompt> (acos 1D++0) ; No, you can't write that in SBCL, but ber with me.
arithmetic error FLOATING-POINT-INEXACT signalled
   [Condition of type FLOATING-POINT-INEXACT]

Restarts:
 0: [RETRY] Retry SLIME REPL evaluation request.
 1: [*ABORT] Return to SLIME's top level.
 2: [REMOVE-FD-HANDLER] Remove #<SB-IMPL::HANDLER INPUT on descriptor 8: #<CLOSURE (LABELS SWANK/SBCL::RUN :IN SWANK/BACKEND:ADD-FD-HANDLER) {12974D1D}>>
 3: [ABORT] Exit debugger, returning to top level.


LW prompt> (acos 1D++0)
#C(6.283185307179586D0 1D+-0 #| 1D+-0 is double-float not-a-number |#)



ACOS (and friends) also take complex numbers.

CL-USER 19 > (acos #C( 42 42))
#C(0.785469 -4.7773905)


Things get even more interesting when you pass to ACOS (and friends) a complex number with an infinity RE or IM part.


LW prompt> (acos (complex 42 1D++0))
#C(1D+-0 #| 1D+-0 is double-float not-a-number |# -1D++0 #| -1D++0 is double-float minus-infinity |#)

CCL prompt> (acos (complex 1.0 1D++0))
#C(1.5707963267948966D0 -1D++0)


SCBL prompt> (acos (complex 1.0 1D++0))
arithmetic error FLOATING-POINT-INEXACT signalled
   [Condition of type FLOATING-POINT-INEXACT]

Restarts:
 0: [RETRY] Retry SLIME REPL evaluation request.
 1: [*ABORT] Return to SLIME's top level.
 2: [REMOVE-FD-HANDLER] Remove #<SB-IMPL::HANDLER INPUT on descriptor 8: #<CLOSURE (LABELS SWANK/SBCL::RUN :IN SWANK/BACKEND:ADD-FD-HANDLER) {12974D1D}>>
 3: [ABORT] Exit debugger, returning to top level.




Now, now, now.  We do not like this state of affairs, do we?

So, the question is: what should ACOS (and friends) do in these cases?

What about the LIA ISO/IEC 10967 standards?

All the best

Marco








--
Marco Antoniotti, Associate Professor tel. +39 - 02 64 48 79 01
DISCo, Università Milano Bicocca U14 2043 http://bimib.disco.unimib.it
Viale Sarca 336
I-20126 Milan (MI) ITALY

Please check: http://cdac2019.lakecomoschool.org
Please check: http://troncopackage.org
Please check: https://www.frontiersin.org/research-topics/7394/network-bioscience

Please note that I am not checking my Spam-box anymore.
Please do not forward this email without asking me first (cum grano salis).