[Armedbear-devel] EQUALP raises type-error comparing large bignums to floats (patch attached)
Massimiliano Ghilardi
massimiliano.ghilardi+abcl at gmail.com
Sun Jan 25 19:19:40 UTC 2015
If a bignum exceeds the largest representable single-float,
EQUALP will raise a type-error when comparing it to a single-float.
The same problem happens with double-floats.
I am reporting this because my understanding of CLHS
http://www.lispworks.com/documentation/lw51/CLHS/Body/f_equalp.htm#equalp
tells that EQUALP is not supposed to raise errors at all:
"Exceptional Situations: None."
How to reproduce:
;; =========== double-floats ===========
(= (ash 1 1024) most-positive-double-float)
NIL
(equalp (ash 1 1024) most-positive-double-float)
; Evaluation aborted on #<TYPE-ERROR {215F90FE}>.
;; =========== single-floats ===========
(= 340282360000000000000000000000000000000 0.0f0)
NIL
(equalp 340282360000000000000000000000000000000 0.0f0)
; Evaluation aborted on #<TYPE-ERROR {1CFFC364}>.
In attachment the detailed stacktrace and a proposed patch to fix this
problem.
Regards,
Massimiliano Ghilardi
-------------- next part --------------
CL-USER> (= 340282360000000000000000000000000000000 0.0f0)
NIL
CL-USER> (equalp 340282360000000000000000000000000000000 0.0f0)
; Evaluation aborted on #<TYPE-ERROR {1CFFC364}>.
#|
The value 340282360000000000000000000000000000000 is too large to be converted to a single float.
[Condition of type TYPE-ERROR]
Restarts:
0: [RETRY] Retry SLIME REPL evaluation request.
1: [*ABORT] Return to SLIME's top level.
2: [ABORT] Abort thread.
Backtrace:
0: (#<FUNCTION {1BEB6543}> #<TYPE-ERROR {64477E27}> #<FUNCTION {1BEB6543}>)
1: (APPLY #<FUNCTION {1BEB6543}> (#<TYPE-ERROR {64477E27}> #<FUNCTION {1BEB6543}>))
2: (SYSTEM::RUN-HOOK SYSTEM::*INVOKE-DEBUGGER-HOOK* #<TYPE-ERROR {64477E27}> #<FUNCTION {1BEB6543}>)
3: (INVOKE-DEBUGGER #<TYPE-ERROR {64477E27}>)
4: org.armedbear.lisp.Lisp.error(Lisp.java:382)
5: org.armedbear.lisp.Bignum.floatValue(Bignum.java:292)
6: org.armedbear.lisp.Bignum.equalp(Bignum.java:219)
7: org.armedbear.lisp.Primitives$pf_equalp.execute(Primitives.java:405)
8: (EQUALP 340282360000000000000000000000000000000 0.0)
9: (SYSTEM::%EVAL (EQUALP 340282360000000000000000000000000000000 0.0))
10: (EVAL (EQUALP 340282360000000000000000000000000000000 0.0))
--more--
|#
-------------- next part --------------
A non-text attachment was scrubbed...
Name: abcl-1.3.1-equalp-type-error.diff
Type: text/x-patch
Size: 938 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/armedbear-devel/attachments/20150125/b10d7dae/attachment.bin>
-------------- next part --------------
_______________________________________________
Armedbear-devel mailing list
Armedbear-devel at common-lisp.net
http://mailman.common-lisp.net/cgi-bin/mailman/listinfo/armedbear-devel
More information about the armedbear-devel
mailing list