Fix BigDecimal result for -Long.MIN_VALUE / -1L
BigDecimal produced the result -9223372036854775808 (== -2^64 == Long.MIN_VALUE) instead of 9223372036854775808 (== 2^64). This was because BigDecimal incorrectly used long arithmetic for this calculation, which overflows back to Long.MIN_VALUE. This bug didn't happen in the case where the result scale required adjustment (diffScale != 0): The bitLength(power of ten) calculation rounds up to whole bits, and therefore is generous enough not to fall into this trap in the corner case. Public bug: https://code.google.com/p/android/issues/detail?id=196555 Bug: 26105053 Change-Id: Ie4b1d08c9074d59d854c664ef17aedcaae24c56e
Loading
Please sign in to comment