[armedbear-cvs] r11955 - in trunk/abcl: src/org/armedbear/lisp test/lisp/abcl
Erik Huelsmann
ehuelsmann at common-lisp.net
Tue May 26 18:59:31 UTC 2009
Author: ehuelsmann
Date: Tue May 26 14:59:27 2009
New Revision: 11955
Log:
Fix some failures in ABCL's own test suite; some by fixing the
expected output.
Modified:
trunk/abcl/src/org/armedbear/lisp/DoubleFloat.java
trunk/abcl/src/org/armedbear/lisp/MathFunctions.java
trunk/abcl/src/org/armedbear/lisp/SingleFloat.java
trunk/abcl/test/lisp/abcl/math-tests.lisp
Modified: trunk/abcl/src/org/armedbear/lisp/DoubleFloat.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/DoubleFloat.java (original)
+++ trunk/abcl/src/org/armedbear/lisp/DoubleFloat.java Tue May 26 14:59:27 2009
@@ -484,6 +484,8 @@
final LispThread thread = LispThread.currentThread();
double divisor = ((SingleFloat)obj).value;
double quotient = value / divisor;
+ if (value != 0)
+ MathFunctions.OverUnderFlowCheck(quotient);
if (quotient >= Integer.MIN_VALUE && quotient <= Integer.MAX_VALUE) {
int q = (int) quotient;
return thread.setValues(Fixnum.getInstance(q),
@@ -516,6 +518,8 @@
double divisor = ((DoubleFloat)obj).value;
// Debug.trace("divisor = " + divisor);
double quotient = value / divisor;
+ if (value != 0)
+ MathFunctions.OverUnderFlowCheck(quotient);
// Debug.trace("quotient = " + quotient);
if (quotient >= Integer.MIN_VALUE && quotient <= Integer.MAX_VALUE) {
int q = (int) quotient;
Modified: trunk/abcl/src/org/armedbear/lisp/MathFunctions.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/MathFunctions.java (original)
+++ trunk/abcl/src/org/armedbear/lisp/MathFunctions.java Tue May 26 14:59:27 2009
@@ -771,6 +771,45 @@
return number;
}
+ /** Checks number for over- or underflow values.
+ *
+ * @param number
+ * @return number or signals an appropriate error
+ * @throws org.armedbear.lisp.ConditionThrowable
+ */
+ final static float OverUnderFlowCheck(float number)
+ throws ConditionThrowable
+ {
+ if (TRAP_OVERFLOW) {
+ if (Float.isInfinite(number))
+ error(new FloatingPointOverflow(NIL));
+ }
+ if (TRAP_UNDERFLOW) {
+ if (number == 0)
+ error(new FloatingPointUnderflow(NIL));
+ }
+ return number;
+ }
+
+ /** Checks number for over- or underflow values.
+ *
+ * @param number
+ * @return number or signals an appropriate error
+ * @throws org.armedbear.lisp.ConditionThrowable
+ */
+ public final static double OverUnderFlowCheck(double number)
+ throws ConditionThrowable
+ {
+ if (TRAP_OVERFLOW) {
+ if (Double.isInfinite(number))
+ error(new FloatingPointOverflow(NIL));
+ }
+ if (TRAP_UNDERFLOW) {
+ if (number == 0)
+ error(new FloatingPointUnderflow(NIL));
+ }
+ return number;
+ }
// Adapted from SBCL.
/** Return the exponent of base taken to the integer exponent power
*
Modified: trunk/abcl/src/org/armedbear/lisp/SingleFloat.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/SingleFloat.java (original)
+++ trunk/abcl/src/org/armedbear/lisp/SingleFloat.java Tue May 26 14:59:27 2009
@@ -489,6 +489,8 @@
final LispThread thread = LispThread.currentThread();
float divisor = ((SingleFloat)obj).value;
float quotient = value / divisor;
+ if (value != 0)
+ MathFunctions.OverUnderFlowCheck(quotient);
if (quotient >= Integer.MIN_VALUE && quotient <= Integer.MAX_VALUE) {
int q = (int) quotient;
return thread.setValues(Fixnum.getInstance(q),
@@ -519,6 +521,8 @@
final LispThread thread = LispThread.currentThread();
double divisor = ((DoubleFloat)obj).value;
double quotient = value / divisor;
+ if (value != 0)
+ MathFunctions.OverUnderFlowCheck(quotient);
if (quotient >= Integer.MIN_VALUE && quotient <= Integer.MAX_VALUE) {
int q = (int) quotient;
return thread.setValues(Fixnum.getInstance(q),
Modified: trunk/abcl/test/lisp/abcl/math-tests.lisp
==============================================================================
--- trunk/abcl/test/lisp/abcl/math-tests.lisp (original)
+++ trunk/abcl/test/lisp/abcl/math-tests.lisp Tue May 26 14:59:27 2009
@@ -305,8 +305,8 @@
(deftest expt.15
(expt 1 1/2)
- #+clisp 1
- #-clisp 1.0)
+ #+(or clisp abcl) 1
+ #-(or clisp abcl) 1.0)
(deftest expt.16
(expt 9 1/2)
@@ -429,11 +429,11 @@
(deftest atanh.1
(atanh 2)
- #C(0.54930615 1.5707964))
+ #C(0.54930615 -1.5707964))
(deftest atanh.2
(atanh -2)
- #C(-0.54930615 -1.5707964))
+ #C(-0.54930615 1.5707964))
(deftest truncate.1
(truncate least-positive-single-float)
More information about the armedbear-cvs
mailing list