You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@daffodil.apache.org by "Steve Lawrence (JIRA)" <ji...@apache.org> on 2019/02/25 15:44:00 UTC

[jira] [Commented] (DAFFODIL-2076) fn:ceiling does not work on xs:decimal

    [ https://issues.apache.org/jira/browse/DAFFODIL-2076?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16777015#comment-16777015 ] 

Steve Lawrence commented on DAFFODIL-2076:
------------------------------------------

Note that the issue here is that we use {{BigDecimal.round(...)}}, which rounds to some amount of *significant digits*. Instead, we should really be using {{BigDecimal.setScale}}, which rounds to some amount of *digits after the decimal place*.

As part of this bug, we should scrutinize all of our uses of round() and setScale() and ensure that we are using the correct function for various rounding operations. 

> fn:ceiling does not work on xs:decimal
> --------------------------------------
>
>                 Key: DAFFODIL-2076
>                 URL: https://issues.apache.org/jira/browse/DAFFODIL-2076
>             Project: Daffodil
>          Issue Type: Bug
>          Components: Back End
>    Affects Versions: 2.3.0
>            Reporter: Steve Lawrence
>            Priority: Blocker
>             Fix For: 2.4.0
>
>
> The fn:ceiling function (and likely other related functions that do rounding-like operations) does not correctly work on xs:decimal's. For example:
> {code}
> fn:ceiling(xs:decimal(0.125))
> {code}
> results in 0.125. The expected value is 1.
> Floats and doubles do round correctly, so a temporary work around is to cast any decimals that are passed into fn:ceiling to xs:doubles.
> Note that commit a20ff4172807f5e0264ce68142f15f9798df1e8b changed the behavior of {{div}} to always return an xs:decimal instead of an xs:float/double, so any functions that try to fn:ceiling a division will likely run into this issue and require the xs:double cast as a workaround.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)