diff options
Diffstat (limited to 'libjava/classpath/vm/reference/java')
-rw-r--r-- | libjava/classpath/vm/reference/java/lang/VMFloat.java | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/libjava/classpath/vm/reference/java/lang/VMFloat.java b/libjava/classpath/vm/reference/java/lang/VMFloat.java index 2e7f439..1534813 100644 --- a/libjava/classpath/vm/reference/java/lang/VMFloat.java +++ b/libjava/classpath/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 |