Hi,
While merging in the Sun double/float toString/parsing in IKVM, I found that
the Float/VMFloat interface wasn't properly factored to support this. This
patch (already committed) fixes that.
Regards,
Jeroen
2007-05-11 Jeroen Frijters <[EMAIL PROTECTED]>
* java/lang/Float.java
(toString(float)): Call VMFloat instead of VMDouble.
(parseFloat): Call VMFloat. Fixed comment.
* vm/reference/java/lang/VMFloat.java
(toString, parseFloat): New methods.
NEWS: added note about these changes.
Index: java/lang/Float.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/Float.java,v
retrieving revision 1.35
diff -u -r1.35 Float.java
--- java/lang/Float.java 10 Dec 2006 20:25:44 -0000 1.35
+++ java/lang/Float.java 11 May 2007 06:07:52 -0000
@@ -181,7 +181,7 @@
*/
public static String toString(float f)
{
- return VMDouble.toString(f, true);
+ return VMFloat.toString(f);
}
/**
@@ -331,9 +331,9 @@
*
* @param str the <code>String</code> to convert
* @return the <code>float</code> value of <code>s</code>
- * @throws NumberFormatException if <code>s</code> cannot be parsed as a
+ * @throws NumberFormatException if <code>str</code> cannot be parsed as a
* <code>float</code>
- * @throws NullPointerException if <code>s</code> is null
+ * @throws NullPointerException if <code>str</code> is null
* @see #MIN_VALUE
* @see #MAX_VALUE
* @see #POSITIVE_INFINITY
@@ -342,9 +342,7 @@
*/
public static float parseFloat(String str)
{
- // XXX Rounding parseDouble() causes some errors greater than 1 ulp from
- // the infinitely precise decimal.
- return (float) Double.parseDouble(str);
+ return VMFloat.parseFloat(str);
}
/**
Index: vm/reference/java/lang/VMFloat.java
===================================================================
RCS file: /cvsroot/classpath/classpath/vm/reference/java/lang/VMFloat.java,v
retrieving revision 1.2
diff -u -r1.2 VMFloat.java
--- vm/reference/java/lang/VMFloat.java 2 Jul 2005 20:33:08 -0000 1.2
+++ vm/reference/java/lang/VMFloat.java 11 May 2007 06:08:52 -0000
@@ -108,4 +108,26 @@
*/
static native float intBitsToFloat(int bits);
+ /**
+ * @param f the <code>float</code> to convert
+ * @return the <code>String</code> representing the <code>float</code>
+ */
+ static String toString(float f)
+ {
+ return VMDouble.toString(f, true);
+ }
+
+ /**
+ * @param str the <code>String</code> to convert
+ * @return the <code>float</code> value of <code>s</code>
+ * @throws NumberFormatException if <code>str</code> cannot be parsed as a
+ * <code>float</code>
+ * @throws NullPointerException if <code>str</code> is null
+ */
+ static float parseFloat(String str)
+ {
+ // XXX Rounding parseDouble() causes some errors greater than 1 ulp from
+ // the infinitely precise decimal.
+ return (float) Double.parseDouble(str);
+ }
} // class VMFloat