[
https://issues.apache.org/jira/browse/GROOVY-7385?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14508277#comment-14508277
]
Sean Gilligan edited comment on GROOVY-7385 at 4/23/15 1:33 AM:
----------------------------------------------------------------
I'm doing work with (digital) currency and am seeking to avoid any rounding or
truncation, so am looking at everything with an eagle eye. Note that JSR-354
(Java Money) include a subclass of {{Number}} called
[NumberValue|https://github.com/JavaMoney/jsr354-api/blob/master/src/main/java/javax/money/NumberValue.java]
that adds methods named {{longValueExact()}}, {{doubleValueExact()}}, etc.
that throw {{ArithmeticException}} if truncation would have occurred.
was (Author: msgilligan):
I'm doing work with (digital) currency and am seeking to avoid any rounding or
truncation, so am looking at everything with an eagle eye. Note that JSR-354
(Java Money) include a subclass of {{Number}} called
[NumberValue}https://github.com/JavaMoney/jsr354-api/blob/master/src/main/java/javax/money/NumberValue.java]
that adds methods named {{longValueExact()}}, {{doubleValueExact()}}, etc.
that throw {{ArithmeticException}} if truncation would have occurred.
> Invalid Integer & Long literals compile when they shouldn't
> -----------------------------------------------------------
>
> Key: GROOVY-7385
> URL: https://issues.apache.org/jira/browse/GROOVY-7385
> Project: Groovy
> Issue Type: Bug
> Components: syntax
> Affects Versions: 2.4.3
> Environment: Mac OS X
> Reporter: Sean Gilligan
> Assignee: Jochen Theodorou
>
> 2147483648I should be an invalid Integer literal.
> 9223372036854775808L should be an invalid Long literal.
> Both currently compile (and produce an unexpected value -- well, it would be
> the expected value in 2's complement math)
> I created some unit tests to show the problem -- not sure if I put them in
> the right place, but they do fail as I expect them to.
> The Github PR is here:
> https://github.com/groovy/groovy-core/pull/657
> The build output is here:
> http://ci.groovy-lang.org/viewLog.html?buildId=16410&buildTypeId=Groovy_Jdk7Build
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)