[SPAM] BigInteger

Raif S. Naffah raif@swiftdsl.com.au
Thu Aug 24 17:02:00 GMT 2006


hello Aleksy,
On Friday 25 August 2006 01:37, Aleksy Schubert wrote:
> ...
> The constructor
>> public BigInteger(int signum, byte[] magnitude)
>> basically constructs the integer based on the array of bytes.
> It tries to contract the array of integers, but in fact it
> does that only provided that the number represented by
> magnitude can fit into 32 bits.

i'm not entirely sure about what you mean by that. if you mean that it tries 
to fit the supplied bytes in an array of ints (32-bit entities) then yes.
> ...
> To see the consequences, consider the following example.
>> Suppose we start with the following array of bytes:
>> a = { 32, 33, 34, 35, 36, 37, 0, 0, 0, 0, 0, 0 }
>> integer = new BigInteger(a)
>> returns a number with integer.words.length==3 and
> b = integer.toByteArray() gives the result
>> { 32, 33, 34, 35, 36, 37, 0, 0, 0 }
>> which is a bit unexpected.

indeed. i'm attaching a Mauve test to show that this is not the case with the 
current BigInteger implementation in GNU Classpath CVS Head. was this the 
source you inspected?
cheers;
rsn
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TestOfToByteArray.java
Type: text/x-java
Size: 1626 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/java/attachments/20060824/1967fd6b/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/java/attachments/20060824/1967fd6b/attachment.sig>


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /