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:16:51 UTC
svn commit: r1368775 -
/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/cast/CastToFloatOperation.java
Author: prestonc
Date: Fri Aug 3 02:16:51 2012
New Revision: 1368775
URL: http://svn.apache.org/viewvc?rev=1368775&view=rev
Log:
Attempt to fix the float casting error.
Modified:
incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/cast/CastToFloatOperation.java
Modified: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/cast/CastToFloatOperation.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/cast/CastToFloatOperation.java?rev=1368775&r1=1368774&r2=1368775&view=diff
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/cast/CastToFloatOperation.java (original)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/cast/CastToFloatOperation.java Fri Aug 3 02:16:51 2012
@@ -119,7 +119,16 @@ public class CastToFloatOperation extend
if (negativeValue) {
value *= -1;
}
- valueFloat = (float) (value * Math.pow(10, decimalPlace));
+ valueFloat = value;
+ while (decimalPlace != 0) {
+ if (decimalPlace > 0) {
+ --decimalPlace;
+ valueFloat *= 10;
+ } else {
+ ++decimalPlace;
+ valueFloat *= 0.1;
+ }
+ }
}
dOut.write(ValueTag.XS_FLOAT_TAG);