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/24 00:11:25 UTC
svn commit: r1376726 -
/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/arithmetic/DivideOperation.java
Author: prestonc
Date: Thu Aug 23 22:11:25 2012
New Revision: 1376726
URL: http://svn.apache.org/viewvc?rev=1376726&view=rev
Log:
Altered the divide operation for Year Month to keep decimal places until the final output.
Modified:
incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/arithmetic/DivideOperation.java
Modified: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/arithmetic/DivideOperation.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/arithmetic/DivideOperation.java?rev=1376726&r1=1376725&r2=1376726&view=diff
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/arithmetic/DivideOperation.java (original)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/arithmetic/DivideOperation.java Thu Aug 23 22:11:25 2012
@@ -402,19 +402,19 @@ public class DivideOperation extends Abs
@Override
public void operateYMDurationDouble(IntegerPointable intp, DoublePointable doublep, DataOutput dOut)
throws SystemException, IOException {
- int value = intp.intValue();
- value /= doublep.intValue();
+ double value = intp.doubleValue();
+ value /= doublep.doubleValue();
dOut.write(ValueTag.XS_YEAR_MONTH_DURATION_TAG);
- dOut.writeInt(value);
+ dOut.writeInt((int) value);
}
@Override
public void operateYMDurationFloat(IntegerPointable intp, FloatPointable floatp, DataOutput dOut)
throws SystemException, IOException {
- int value = intp.intValue();
- value /= floatp.intValue();
+ float value = intp.floatValue();
+ value /= floatp.floatValue();
dOut.write(ValueTag.XS_YEAR_MONTH_DURATION_TAG);
- dOut.writeInt(value);
+ dOut.writeInt((int) value);
}
@Override
@@ -448,44 +448,30 @@ public class DivideOperation extends Abs
public int operateIntDecimal(int intValue, XSDecimalPointable decp2) throws SystemException, IOException {
abvsInner.reset();
- XSDecimalPointable decp1 = (XSDecimalPointable) XSDecimalPointable.FACTORY.createPointable();
- decp1.set(abvsInner.getByteArray(), abvsInner.getStartOffset(), XSDecimalPointable.TYPE_TRAITS.getFixedLength());
- decp1.setDecimal(intValue, (byte) 0);
// Prepare
- long value1 = decp1.getDecimalValue();
- long value2 = decp2.getDecimalValue();
- byte place1 = decp1.getDecimalPlace();
- byte place2 = decp2.getDecimalPlace();
+ double value1 = intValue;
+ double value2 = decp2.doubleValue();
if (value2 == 0) {
throw new SystemException(ErrorCode.FOAR0001);
}
// Divide
value1 /= value2;
- place1 -= place2;
// Save
- decp2.setDecimal(value1, place1);
- return decp2.intValue();
+ return (int) value1;
}
public int operateDecimalInt(XSDecimalPointable decp1, int intValue) throws SystemException, IOException {
abvsInner.reset();
- XSDecimalPointable decp2 = (XSDecimalPointable) XSDecimalPointable.FACTORY.createPointable();
- decp2.set(abvsInner.getByteArray(), abvsInner.getStartOffset(), XSDecimalPointable.TYPE_TRAITS.getFixedLength());
- decp2.setDecimal(intValue, (byte) 0);
// Prepare
- long value1 = decp1.getDecimalValue();
- long value2 = decp2.getDecimalValue();
- byte place1 = decp1.getDecimalPlace();
- byte place2 = decp2.getDecimalPlace();
+ double value1 = decp1.doubleValue();
+ double value2 = intValue;
if (value2 == 0) {
throw new SystemException(ErrorCode.FOAR0001);
}
// Divide
value1 /= value2;
- place1 -= place2;
// Save
- decp2.setDecimal(value1, place1);
- return decp2.intValue();
+ return (int) value1;
}
}
\ No newline at end of file