This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Float.java parseFloat addition patch


>>>>> "Edgar" == Edgar Villanueva <edgar@villanueva.com> writes:

Edgar> This function was missing.

I chose a slightly different implementation.  The spec says that this
should work like Double.valueOf.  I made it work that way, but a bit
more efficiently -- we don't create a new object.

Once I'm satisfied that it builds ok I plan to check it in.

2001-02-08  Tom Tromey  <tromey@redhat.com>

	* java/lang/Float.java (parseFloat): New method.

Tom

Index: java/lang/Float.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/Float.java,v
retrieving revision 1.5
diff -u -r1.5 Float.java
--- Float.java	2000/11/17 04:51:25	1.5
+++ Float.java	2001/02/09 02:03:43
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998, 1999, 2000  Free Software Foundation
+/* Copyright (C) 1998, 1999, 2000, 2001  Free Software Foundation
 
    This file is part of libgcj.
 
@@ -47,6 +47,14 @@
   public Float (String s) throws NumberFormatException
   {
     this.value = valueOf (s).floatValue ();
+  }
+
+  public static float parseFloat (String s) throws NumberFormatException
+  {
+    // The spec says that parseFloat() should work like
+    // Double.valueOf().  This is equivalent, in our implementation,
+    // but more efficient.
+    return (float) Double.parseDouble (s);
   }
 
   public String toString ()


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]