review request for 6622432

Christian Thalinger Christian.Thalinger at Sun.COM
Tue Feb 17 11:15:15 UTC 2009


On Mon, 2009-02-16 at 14:33 -0800, Xiaobin Lu wrote:
> Webrev: http://webrev.invokedynamic.info/xiaobin.lu/6622432/
> 
> 6622432: RFE: Performance improvements to java.math.BigDecimal

<snip>

> As you know, the division operation is expensive and the 
> algorithm to compare with the ten's power array can be made more 
> efficiently by correlating the bit length of the number with the index 
> to the array so that the time to compute the precision is O(1) rather 
> than being O(n) (where n is the length of the array). And that is 
> exactly what we are doing in the webrev. First, we get the bit length of 
> the number and then multiply it with log2 (10 base), use the result to 
> index to a dynamically expanded ten's power array so that division 
> operation can be avoided completely.

Actually I'm not reviewing the webrev but I have some questions.

1. Is bitCount() called often and performance critical?  There is a RFE
(6378821) to intrinsify it and I am thinking about to implement it.

2. Why is BigInteger using it's own implementation of bit-count
(bitCnt()) instead of using Integer.bitCount()?

-- Christian




More information about the core-libs-dev mailing list