ogawaffm opened a new pull request, #65:
URL: https://github.com/apache/velocity-engine/pull/65

   ## Problem
   
   `MathUtils.toBigDecimal(Number)` currently converts generic `Number` 
instances through `doubleValue()` before creating a `BigDecimal`.
   
   This can lose precision for large integral values, for example 
`Long.MAX_VALUE`.
   
   As a result, VTL arithmetic and comparisons involving a `Long` and a 
`BigDecimal` may produce unexpected results.
   
   ## Example
   
   ```vtl
   #set($L  = 9223372036854775807)  ## Long.MAX_VALUE
   #set($BI = 9223372036854775808)  ## BigInteger
   
   #set($BD0 = ($BI + 0.0) - $BI)  ## BigDecimal 0.0
   #set($BDL = $BI - 1.0)          ## BigDecimal 9223372036854775807.0
   
   #set($d = $L + $BD0)
   L + BigDecimal(0.0)       = $d ($d.class.name)
   
   L == BigDecimal(Long.MAX) = #if($L == $BDL)true#{else}false#end
   L >  BigDecimal(Long.MAX) = #if($L >  $BDL)true#{else}false#end
   vtl```
   
   


-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to