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

ASF GitHub Bot commented on GROOVY-7665:
----------------------------------------

Github user asfgit closed the pull request at:

    https://github.com/apache/incubator-groovy/pull/183


> JsonSlurperCharSource decimal parsing producing unexpected results
> ------------------------------------------------------------------
>
>                 Key: GROOVY-7665
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7665
>             Project: Groovy
>          Issue Type: Bug
>          Components: JSON
>    Affects Versions: 2.4.5
>            Reporter: John Wagenleitner
>            Priority: Minor
>
> When using the JsonParserType.CHARACTER_SOURCE decimal numbers are first 
> parsed to double value and that value is used to construct the BigDecimal to 
> return.  This can produce some unexpected results.
> For example:
> {code}
> ​import groovy.json.*
> def parser = new JsonSlurper().setType(JsonParserType.CHARACTER_SOURCE)
> def json = parser.parseText('{"num": 123.40}')
> assert json.num instanceof BigDecimal
> assert 123.40G == json.num​
> {code}
> Fails with:
> {code}
> Assertion failed: 
> assert 123.40G == json.num
>                |  |    |
>                |  |    123.400000000000005684341886080801486968994140625
>                |  [num:123.400000000000005684341886080801486968994140625]
>                false
>       at Script1.run(Script1.groovy:8)
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to