BigDecimal stores a signed decimal number as an unscaled value with a 32-bit integer scale. The unscaled value is stored in an instance of the java.math.BigInteger class.

BigInteger is an immutable class that represents a signed integer of arbitrary precision. It stores its value in two's complement format (all bits are flipped—Is to 0s and 0s to

1s—and 1 is added to the result to be compatible with the two's complement format used by Java's byte integer, short integer, integer, and long integer types).

NOTE: Check out Wikipedia's "Two's complement" entry

(http://en.wikipedia.org/wiki/Two%27s_complement) to learn more about two's complement.

BigInteger declares three convenience constants: ONE, TEN, and ZERO. Each constant is the BigInteger equivalent of 1, 10, and 0.

BigInteger also declares a variety of useful constructors and methods. A few of these constructors and methods are described in Table 6-4.

Table 6-4. BigInteger Constructors and Methods

Method

Was this article helpful?

## Post a comment