You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Richard Zschech (JIRA)" <ji...@apache.org> on 2009/12/17 11:50:18 UTC

[jira] Commented: (HARMONY-6406) Combination of multiply and compareTo BigDecimal methods returns unexpected result

    [ https://issues.apache.org/jira/browse/HARMONY-6406?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12791869#action_12791869 ] 

Richard Zschech commented on HARMONY-6406:
------------------------------------------

I've found the issue in the aproxPrecision method:

private int aproxPrecision() {
        return ((precision > 0)
        ? precision
                : (int)((this.bitLength - 1) * LOG10_2) + 1);
}

The "+ 1" should only be applied to the computed approximation not to the previously computed precision by moving the first bracket on line 2 to line 4:

private int aproxPrecision() {
        return (precision > 0)
        ? precision
                : ((int)((this.bitLength - 1) * LOG10_2) + 1) ;
}

> Combination of multiply and compareTo BigDecimal methods returns unexpected result
> ----------------------------------------------------------------------------------
>
>                 Key: HARMONY-6406
>                 URL: https://issues.apache.org/jira/browse/HARMONY-6406
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>    Affects Versions: 5.0M12
>            Reporter: Richard Zschech
>
> The following test fails:
> BigDecimal testInstance = BigDecimal.TEN.multiply(new BigDecimal("0.1"));
> int result = testInstance.compareTo(new BigDecimal("1.00"));
> assertEquals(0, result);
> I expect 'result' to be 0, but am obtaining -1.

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