stevedlawrence commented on a change in pull request #179: Return xs:decimal 
when dividing xs:long
URL: https://github.com/apache/incubator-daffodil/pull/179#discussion_r254818130
 
 

 ##########
 File path: 
daffodil-runtime1/src/main/scala/org/apache/daffodil/dpath/NumericOps.scala
 ##########
 @@ -174,13 +174,7 @@ case object TimesLong extends NumericOp {
   def operate(v1: JNumber, v2: JNumber): JNumber = { asLong(v1) * asLong(v2) }
 }
 case object DivLong extends NumericOp {
-  def operate(v1: JNumber, v2: JNumber): JNumber = {
-    val v2l = asLong(v2)
-    if (v2l == 0) {
-      throw new ArithmeticException("/ by zero")
-    }
-    asDouble(v1) / v2l
-  }
+  def operate(v1: JNumber, v2: JNumber): JBigDecimal = { 
DivDecimal.operate(v1, v2) }
 
 Review comment:
   Yeah, after taking a look I see now that the convergedArgType is based on 
the arguemtns and not the expected result. So Div{Long,Int,etc} are divisions 
based on the arguments.
   
   However, I think that means Div{Integer-like things} needs to be updated, 
similar to the change you've made for DivLong. So DivLong, DIvShort, 
DIvUnsignedBYte, etc. all have the same issue.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to