harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r448768 - /incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/FloatingPointParser.java
Date Fri, 22 Sep 2006 02:10:39 GMT
Author: pyang
Date: Thu Sep 21 19:10:38 2006
New Revision: 448768

URL: http://svn.apache.org/viewvc?view=rev&rev=448768
Log:
Apply the third part of patch for HARMONY-747(java.lang.Doulbe.parseDouble(String) does not
support Hex number)

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/FloatingPointParser.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/FloatingPointParser.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/FloatingPointParser.java?view=diff&rev=448768&r1=448767&r2=448768
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/FloatingPointParser.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/FloatingPointParser.java
Thu Sep 21 19:10:38 2006
@@ -336,6 +336,8 @@
     private final int EXPONENT_WIDTH;
 
     private final int MANTISSA_WIDTH;
+    
+    private final long EXPONENT_BASE;
 
     private long sign;
 
@@ -346,6 +348,8 @@
     public HexStringParser(int exponent_width, int mantissa_width) {
         this.EXPONENT_WIDTH = exponent_width;
         this.MANTISSA_WIDTH = mantissa_width;
+        
+        this.EXPONENT_BASE = ~(-1L << (exponent_width - 1));
 
     }
 
@@ -403,12 +407,22 @@
 
     // Parses the sign field
     private void parseHexSign(String signStr) {
-        // TODO
+        this.sign = signStr.equals("-") ? 1 : 0; //$NON-NLS-1$
     }
 
     // Parses the exponent field
     private void parseExponent(String exponentStr) {
-        // TODO
+        char leadingChar = exponentStr.charAt(0);
+        int sign = (leadingChar == '-' ? -1 : 1);
+        if (!Character.isDigit(leadingChar)) {
+            exponentStr = exponentStr.substring(1);
+        }
+
+        try {
+            exponent = sign * Long.parseLong(exponentStr) + EXPONENT_BASE;
+        } catch (NumberFormatException e) {
+            exponent = sign * Long.MAX_VALUE;
+        }
     }
 
     // Parses the mantissa field



Mime
View raw message