You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@vxquery.apache.org by pr...@apache.org on 2012/08/03 04:15:34 UTC

svn commit: r1368772 - /incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/cast/CastToDecimalOperation.java

Author: prestonc
Date: Fri Aug  3 02:15:34 2012
New Revision: 1368772

URL: http://svn.apache.org/viewvc?rev=1368772&view=rev
Log:
Update the error reported for string value being to large.

Modified:
    incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/cast/CastToDecimalOperation.java

Modified: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/cast/CastToDecimalOperation.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/cast/CastToDecimalOperation.java?rev=1368772&r1=1368771&r2=1368772&view=diff
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/cast/CastToDecimalOperation.java (original)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/cast/CastToDecimalOperation.java Fri Aug  3 02:15:34 2012
@@ -37,7 +37,7 @@ public class CastToDecimalOperation exte
         double doubleValue = doublep.getDouble();
         byte decimalPlace = 0;
         // Move the decimal
-        while (doubleValue % 1 != 0) {
+        while (doubleValue % 1 != 0 && (doubleValue != 0 || doubleValue != -0)) {
             if (decimalPlace + 1 > XSDecimalPointable.PRECISION) {
                 throw new SystemException(ErrorCode.FOCA0001);
             }
@@ -45,7 +45,7 @@ public class CastToDecimalOperation exte
             doubleValue *= 10;
         }
         // Remove extra zeros
-        while (doubleValue != 0 && doubleValue % 10 == 0) {
+        while (doubleValue % 10 == 0 && (doubleValue != 0 || doubleValue != -0)) {
             doubleValue /= 10;
             --decimalPlace;
         }
@@ -58,8 +58,9 @@ public class CastToDecimalOperation exte
     public void convertFloat(FloatPointable floatp, DataOutput dOut) throws SystemException, IOException {
         float floatValue = floatp.getFloat();
         byte decimalPlace = 0;
+        
         // Move the decimal
-        while (floatValue % 1 != 0) {
+        while (floatValue % 1 != 0 && (floatValue != 0 || floatValue != -0)) {
             if (decimalPlace + 1 > XSDecimalPointable.PRECISION) {
                 throw new SystemException(ErrorCode.FOCA0001);
             }
@@ -67,7 +68,7 @@ public class CastToDecimalOperation exte
             floatValue *= 10;
         }
         // Remove extra zeros
-        while (floatValue != 0 && floatValue % 10 == 0) {
+        while (floatValue % 10 == 0 && (floatValue != 0 || floatValue != -0)) {
             floatValue /= 10;
             --decimalPlace;
         }
@@ -95,7 +96,7 @@ public class CastToDecimalOperation exte
 
         while ((c = charIterator.next()) != ICharacterIterator.EOS_CHAR) {
             if (count + 1 > XSDecimalPointable.PRECISION) {
-                throw new SystemException(ErrorCode.FOCA0001);
+                throw new SystemException(ErrorCode.FOCA0006);
             } else if (Character.isDigit(c)) {
                 value = value * 10 + Character.getNumericValue(c);
                 if (pastDecimal) {