mbeckerle commented on a change in pull request #196: Use setScale() not 
round() when rounding BigDecimals
URL: https://github.com/apache/incubator-daffodil/pull/196#discussion_r266057276
 
 

 ##########
 File path: 
daffodil-runtime1/src/main/scala/org/apache/daffodil/dpath/FNFunctions.scala
 ##########
 @@ -685,7 +685,7 @@ case class FNCeiling(recipe: CompiledDPath, argType: 
NodeInfo.Kind) extends FNOn
 
     case NodeInfo.Decimal => {
       val bd = asBigDecimal(value)
-      bd.round(new MathContext(0, RoundingMode.CEILING))
+      bd.setScale(0, RoundingMode.CEILING)
 
 Review comment:
   If this is a side-effect on this big decimal object, that object could be 
referenced from say, an element in the infoset. A formula elsewhere in the 
schema could be accessing its value and calling a round on it. 
   
   So then the original element would have changed also.
   
   I think you need to make a copy before you setScale. 

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


With regards,
Apache Git Services

Reply via email to