[armedbear-cvs] r12018 - trunk/abcl/src/org/armedbear/lisp

Erik Huelsmann ehuelsmann at common-lisp.net
Tue Jun 16 20:46:11 UTC 2009


Author: ehuelsmann
Date: Tue Jun 16 16:46:06 2009
New Revision: 12018

Log:
Reconstruct NaNs upon reading, if readable output is requested.

Modified:
   trunk/abcl/src/org/armedbear/lisp/DoubleFloat.java
   trunk/abcl/src/org/armedbear/lisp/SingleFloat.java

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 Jun 16 16:46:06 2009
@@ -591,11 +591,18 @@
             sb.append(Symbol.DOUBLE_FLOAT_NEGATIVE_INFINITY.writeToString());
             return sb.toString();
         }
-        if (value != value)
-            return "#<DOUBLE-FLOAT NaN>";
-        String s1 = String.valueOf(value);
+
         LispThread thread = LispThread.currentThread();
-        if (Symbol.PRINT_READABLY.symbolValue(thread) != NIL ||
+        boolean printReadably = Symbol.PRINT_READABLY.symbolValue(thread) != NIL;
+
+        if (value != value) {
+            if (printReadably)
+                return "#.(progn \"Comment: create a NaN.\" (/ 0.0d0 0.0d0))";
+            else
+                return "#<DOUBLE-FLOAT NaN>";
+        }
+        String s1 = String.valueOf(value);
+        if (printReadably ||
             !memq(Symbol.READ_DEFAULT_FLOAT_FORMAT.symbolValue(thread),
                   list(Symbol.DOUBLE_FLOAT, Symbol.LONG_FLOAT)))
         {

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 Jun 16 16:46:06 2009
@@ -580,11 +580,18 @@
             sb.append(Symbol.SINGLE_FLOAT_NEGATIVE_INFINITY.writeToString());
             return sb.toString();
         }
-        if (value != value)
-            return "#<SINGLE-FLOAT NaN>";
-        String s1 = String.valueOf(value);
+
         LispThread thread = LispThread.currentThread();
-        if (Symbol.PRINT_READABLY.symbolValue(thread) != NIL ||
+        boolean printReadably = Symbol.PRINT_READABLY.symbolValue(thread) != NIL;
+
+        if (value != value) {
+            if (printReadably)
+                return "#.(progn \"Comment: create a NaN.\" (/ 0.0s0 0.0s0))";
+            else
+                return "#<SINGLE-FLOAT NaN>";
+        }
+        String s1 = String.valueOf(value);
+        if (printReadably ||
             !memq(Symbol.READ_DEFAULT_FLOAT_FORMAT.symbolValue(thread),
                   list(Symbol.SINGLE_FLOAT, Symbol.SHORT_FLOAT)))
         {




More information about the armedbear-cvs mailing list