vxquery-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From prest...@apache.org
Subject svn commit: r1369965 - /incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/atomic/XSDecimalPointable.java
Date Mon, 06 Aug 2012 20:08:41 GMT
Author: prestonc
Date: Mon Aug  6 20:08:41 2012
New Revision: 1369965

URL: http://svn.apache.org/viewvc?rev=1369965&view=rev
Log:
Update the method to find number of digits with a more reliable method. (Increased precision
back to 18)

Modified:
    incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/atomic/XSDecimalPointable.java

Modified: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/atomic/XSDecimalPointable.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/atomic/XSDecimalPointable.java?rev=1369965&r1=1369964&r2=1369965&view=diff
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/atomic/XSDecimalPointable.java
(original)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/atomic/XSDecimalPointable.java
Mon Aug  6 20:08:41 2012
@@ -13,7 +13,7 @@ import edu.uci.ics.hyracks.data.std.prim
 public class XSDecimalPointable extends AbstractPointable implements IHashable, IComparable,
INumeric {
     private final static int DECIMAL_PLACE_OFFSET = 0;
     private final static int VALUE_OFFSET = 1;
-    public final static int PRECISION = 15;
+    public final static int PRECISION = 18;
 
     public static final ITypeTraits TYPE_TRAITS = new ITypeTraits() {
         private static final long serialVersionUID = 1L;
@@ -163,7 +163,17 @@ public class XSDecimalPointable extends 
     }
 
     public static byte getDigitCount(byte[] bytes, int start) {
-        return (byte) (Math.log10((double) getDecimalValue(bytes, start)) + 1);
+        long value = getDecimalValue(bytes, start);
+        if (value < 0) {
+            value *= -1;
+        }
+        long check = 10;
+        for (byte i = 1; i < PRECISION; i++) {
+            if (value < check)
+                return i;
+            check *= 10;
+        }
+        return PRECISION;
     }
 
     @Override



Mime
View raw message