diff options
author | Jeroen Frijters <jeroen@sumatra.nl> | 2007-05-11 08:07:45 +0000 |
---|---|---|
committer | Jeroen Frijters <jeroen@sumatra.nl> | 2007-05-11 08:07:45 +0000 |
commit | 8c44b249a22a1931ff99e9d88854efb74b6cb27a (patch) | |
tree | f73901d15ae11f7d4d968a79daf8a61cb64270e7 | |
parent | 2adeaed5ad2240a169114fa662ee454a8a8baa54 (diff) | |
download | classpath-8c44b249a22a1931ff99e9d88854efb74b6cb27a.tar.gz |
2007-05-11 Jeroen Frijters <jeroen@frijters.net>
* 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.
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | NEWS | 7 | ||||
-rw-r--r-- | java/lang/Float.java | 10 | ||||
-rw-r--r-- | vm/reference/java/lang/VMFloat.java | 22 |
4 files changed, 42 insertions, 6 deletions
@@ -1,3 +1,12 @@ +2007-05-11 Jeroen Frijters <jeroen@frijters.net> + + * 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. + 2007-05-08 Kyle Galloway <kgallowa@redhat.com> * vm/reference/VMFrame.java (<init>): Add a parameter for the "this" @@ -1,3 +1,10 @@ +New in release 0.96 + +Runtime interface changes: + +* Add VMFloat.toString(float) and VMFloat.parseFloat(String). Default + implementations are the same as previous behavior. + New in release 0.95 (Apr 23, 2007) * Full merge of 1.5 generics work. diff --git a/java/lang/Float.java b/java/lang/Float.java index 1e85922be..dc39ec2af 100644 --- a/java/lang/Float.java +++ b/java/lang/Float.java @@ -181,7 +181,7 @@ public final class Float extends Number implements Comparable<Float> */ public static String toString(float f) { - return VMDouble.toString(f, true); + return VMFloat.toString(f); } /** @@ -331,9 +331,9 @@ public final class Float extends Number implements Comparable<Float> * * @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 final class Float extends Number implements Comparable<Float> */ 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); } /** diff --git a/vm/reference/java/lang/VMFloat.java b/vm/reference/java/lang/VMFloat.java index 2e7f439a4..15348130f 100644 --- a/vm/reference/java/lang/VMFloat.java +++ b/vm/reference/java/lang/VMFloat.java @@ -108,4 +108,26 @@ final class VMFloat */ 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 |