J
Jan Burse
Dear All,
Just notice the following note on Android for
java.lang.BigInteger:
Slow Two's Complement Bitwise Operations
This API includes operations for bitwise operations
in two's complement representation. Two's complement
is not the internal representation used by this
implementation, so such methods may be inefficient.
Use BitSet for high-performance bitwise operations
on arbitrarily-large sequences of bits.
But why should be BitSet any faster than BigInteger? Both
BitSet and BigInteger don't use some sparse representation.
They just allocate an array, in the case of BitSet its a long
array, and in the case of BigInteger int array.
The BigInteger sign does not slow down the process in any way.
Its just that the highest int of the BigInteger carries a sign,
which is arbirarily extended to the left. So BigInteger can
represent:
....1xxxxxx
With an infinite sequence of 1's to the left. And then do
boolean operation. But there is practically no overhead
for that. But what I saw is that BitSet is not immutable,
so this could be a reason. But the two's complement is
not an issue, this is just rubbish.
Right?
Bye
Just notice the following note on Android for
java.lang.BigInteger:
Slow Two's Complement Bitwise Operations
This API includes operations for bitwise operations
in two's complement representation. Two's complement
is not the internal representation used by this
implementation, so such methods may be inefficient.
Use BitSet for high-performance bitwise operations
on arbitrarily-large sequences of bits.
But why should be BitSet any faster than BigInteger? Both
BitSet and BigInteger don't use some sparse representation.
They just allocate an array, in the case of BitSet its a long
array, and in the case of BigInteger int array.
The BigInteger sign does not slow down the process in any way.
Its just that the highest int of the BigInteger carries a sign,
which is arbirarily extended to the left. So BigInteger can
represent:
....1xxxxxx
With an infinite sequence of 1's to the left. And then do
boolean operation. But there is practically no overhead
for that. But what I saw is that BitSet is not immutable,
so this could be a reason. But the two's complement is
not an issue, this is just rubbish.
Right?
Bye