review request for 6622432
Rémi Forax
forax at univ-mlv.fr
Tue Feb 17 13:20:12 UTC 2009
Hi Christian,
Christian Thalinger a écrit :
> 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.
>
It's not related to BigInteger but the fastest multi-dispatch algorithm
that I know relies heavily on
bitCount too (on Long.bitCount).
So you have my vote :)
> 2. Why is BigInteger using it's own implementation of bit-count
> (bitCnt()) instead of using Integer.bitCount()?
>
because Integer.bitCount() was introduced in 1.5 and BigInteger in 1.4.
BigInteger was not retrofited.
> -- Christian
>
Rémi
More information about the core-libs-dev
mailing list