You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Catherine Hope (JIRA)" <ji...@apache.org> on 2009/07/14 13:43:15 UTC

[jira] Updated: (HARMONY-6272) [classlib][math] BigDecimal.divide throws ArrayIndexOufOfBoundsException when called with too large scale

     [ https://issues.apache.org/jira/browse/HARMONY-6272?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Catherine Hope updated HARMONY-6272:
------------------------------------

    Attachment: patch.txt

 Please ignore previous patch - I added the testcase to the wrong junit class.  Now moved in org.apache.harmony.tests.java.math.BigDecimalArithmeticTest

> [classlib][math] BigDecimal.divide throws ArrayIndexOufOfBoundsException when called with too large scale
> ---------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-6272
>                 URL: https://issues.apache.org/jira/browse/HARMONY-6272
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>         Environment: all
>            Reporter: Catherine Hope
>         Attachments: patch.txt
>
>
> BigDecimal.divide(BigDecimal, int, RoundingMode) throws an ArrayIndexOutOfBoundsException when called with a scale that's too large, instead of the expected ArithmeticException.
> testcase:
> BigDecimal bd = (new BigDecimal("4")).divide(new BigDecimal("1"), Integer.MAX_VALUE, 1);
> java.lang.ArrayIndexOutOfBoundsException: Array index out of range: -2147483644
> 	at java.math.Multiplication.multiplyByTenPow(Multiplication.java:409)
> 	at java.math.BigDecimal.movePoint(BigDecimal.java:2062)
> 	at java.math.BigDecimal.movePointLeft(BigDecimal.java:2043)
> The exception is thrown from Multiplication.multiplyByTenPow which is being called with a negative index, though it has a precondition that it should be 0 or above.  This is occurring since there's an unnecessary cast to int after a negation, which means if:
> long l = -(Integer.MAX_VALUE + 1);
> long negate = (int)-l;
> then negate is still set to -(Integer.MAX_VALUE + 1) instead of (Integer.MAX_VALUE + 1)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.