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

Erik Huelsmann ehuelsmann at common-lisp.net
Sat Jan 24 10:24:35 UTC 2009


Author: ehuelsmann
Date: Sat Jan 24 10:24:34 2009
New Revision: 11579

Log:
Add floatValue() and doubleValue() to LispObject and all number classes which didn't have it yet.

Modified:
   trunk/abcl/src/org/armedbear/lisp/Bignum.java
   trunk/abcl/src/org/armedbear/lisp/DoubleFloat.java
   trunk/abcl/src/org/armedbear/lisp/Fixnum.java
   trunk/abcl/src/org/armedbear/lisp/LispObject.java
   trunk/abcl/src/org/armedbear/lisp/Ratio.java
   trunk/abcl/src/org/armedbear/lisp/SingleFloat.java

Modified: trunk/abcl/src/org/armedbear/lisp/Bignum.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/Bignum.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/Bignum.java	Sat Jan 24 10:24:34 2009
@@ -262,6 +262,7 @@
     return value.longValue();
   }
 
+  @Override
   public float floatValue() throws ConditionThrowable
   {
     float f = value.floatValue();
@@ -271,6 +272,7 @@
     return f;
   }
 
+  @Override
   public double doubleValue() throws ConditionThrowable
   {
     double d = value.doubleValue();

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	Sat Jan 24 10:24:34 2009
@@ -241,6 +241,11 @@
     }
 
     @Override
+    public double doubleValue() {
+        return value;
+    }
+
+    @Override
     public Object javaInstance()
     {
         return Double.valueOf(value);

Modified: trunk/abcl/src/org/armedbear/lisp/Fixnum.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/Fixnum.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/Fixnum.java	Sat Jan 24 10:24:34 2009
@@ -311,6 +311,16 @@
       }
   }
 
+  @Override
+  public float floatValue() {
+    return (float)value;
+  }
+
+  @Override
+  public double doubleValue() {
+    return (double)value;
+  }
+
   public static int getInt(LispObject obj) throws ConditionThrowable
   {
     try

Modified: trunk/abcl/src/org/armedbear/lisp/LispObject.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/LispObject.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/LispObject.java	Sat Jan 24 10:24:34 2009
@@ -775,6 +775,20 @@
     return 0;
   }
 
+  public float floatValue() throws ConditionThrowable
+  {
+    type_error(this, Symbol.SINGLE_FLOAT);
+    // Not reached
+    return 0;
+  }
+
+  public double doubleValue() throws ConditionThrowable
+  {
+    type_error(this, Symbol.DOUBLE_FLOAT);
+    // Not reached
+    return 0;
+  }
+
   public LispObject incr() throws ConditionThrowable
   {
     return type_error(this, Symbol.NUMBER);

Modified: trunk/abcl/src/org/armedbear/lisp/Ratio.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/Ratio.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/Ratio.java	Sat Jan 24 10:24:34 2009
@@ -182,11 +182,13 @@
         return false;
     }
 
+    @Override
     public float floatValue()
     {
         return (float) doubleValue();
     }
 
+    @Override
     public double doubleValue()
     {
         double result = numerator.doubleValue() / denominator.doubleValue();

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	Sat Jan 24 10:24:34 2009
@@ -241,6 +241,16 @@
     }
 
     @Override
+    public float floatValue() {
+        return value;
+    }
+
+    @Override
+    public double doubleValue() {
+        return value;
+    }
+
+    @Override
     public Object javaInstance()
     {
         return Float.valueOf(value);




More information about the armedbear-cvs mailing list