Cryptography Reference
In-Depth Information
FIGURE 2.5
B
Array of bytes
1
000 1101
1111 0011
0010 1101
0100 1110
sign bit negative
two's complement
representation
= -1913442992
= -1110010000011001101001010110000 base 2
B
FIGURE 2.6
signum
-1
magnitude[0]
magnitude[1]
1101 0011
0010 1100
Produces BigInteger -54060
= -1101001100101100 base 2
This constructor translates the sign-magnitude representation of an integer into a BigIn-
teger (see Figure 2.6). The integer is sent in as an array of bytes, and the sign is represented
as an integer signum value:
1 for negative,
0 for zero, and
1 for positive.
The magnitude is represented as a big-endian byte array; that is, the most significant
byte is in the [0] position. An invalid signum value or a 0 signum value coupled with a
nonzero magnitude will result in a NumberFormatException. A zero length magnitude array
is permissible and will result in a value of zero regardless of the given signum value.
public BigInteger(String val) throws NumberFormatException
This translates a string containing an optional minus sign followed by a sequence of one
or more decimal digits into a BigInteger. Any extraneous characters (including whitespace)
will result in a NumberFormatException.
Search WWH ::




Custom Search