[cl-debian] Bug#433592: clisp: Float/rational comparison sometimes underflows; should never
J.P. Larocque
piranha at thoughtcrime.us
Wed Jul 18 05:27:21 UTC 2007
Package: clisp
Version: 1:2.41-1
Severity: normal
Hi,
I'm trying to compare a floating-point number and a rational.
According to the rule of float and rational contagion, described in
CLHS 12.1.4.1, and X3J13 issue
CONTAGION-ON-NUMERICAL-COMPARISONS:TRANSITIVE, such a comparison
should always return the mathematically correct result, as if the
floating-point number were first converted to a rational with
RATIONAL. Instead, CLISP signals an underflow condition:
$ clisp -q -x '(< (expt 10 -100) least-positive-short-float)'
*** - floating point underflow
The Implementation Notes for GNU CLISP, sections 12.2.3.1 and
12.2.3.2, don't seem to say anything about comparisons, but mention
two variables which control ANSI-compliance. CLISP behaves the same
when invoked with "-ansi", to set these and any similar variables to
T.
$ clisp -ansi -q -x '(< (expt 10 -100) least-positive-short-float)'
*** - floating point underflow
This X3J13 issue is listed as supported in the Implementation Notes for GNU CLISP:
http://clisp.cons.org/impnotes.html#issues
CLISP behaves as expected if the floating-point number is filtered
through RATIONAL. (Note that CLHS 12.1.4.1 explicitly states "When
rationals and floats are compared by a numerical function, the
function rational is effectively called to convert the float to a
rational and then an exact comparison is performed.")
$ clisp -q -x '(< (expt 10 -100) (rational least-positive-short-float))'
T
$ clisp -q -x '(< (expt 10 -10) (rational least-positive-short-float))'
NIL
I'm fairly certain CLISP is in error.
Thanks,
-- System Information:
Debian Release: 4.0
APT prefers stable
APT policy: (500, 'stable')
Architecture: amd64 (x86_64)
Shell: /bin/sh linked to /bin/bash
Kernel: Linux 2.6.18-12-custom-xen-ws-1
Locale: LANG=C, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Versions of packages clisp depends on:
ii common-lisp-controller 6.9 This is a Common Lisp source and c
ii libc6 2.3.6.ds1-13 GNU C Library: Shared libraries
ii libice6 1:1.0.1-2 X11 Inter-Client Exchange library
ii libncurses5 5.5-5 Shared libraries for terminal hand
ii libreadline5 5.2-2 GNU readline and history libraries
ii libsm6 1:1.0.1-3 X11 Session Management library
ii libx11-6 2:1.0.3-7 X11 client-side library
ii libxext6 1:1.0.1-2 X11 miscellaneous extension librar
ii libxpm4 1:3.5.5-2 X11 pixmap library
clisp recommends no packages.
-- no debconf information
--
J.P. Larocque: <piranha at thoughtcrime.us>, <piranha at ely.ath.cx>
More information about the Cl-debian
mailing list