How BigDecimal is implemented?

The unscaled value of the BigDecimal is stored in a BigInteger. The precision and scale are stored separately in integer fields:

BigInteger intVal
int scale
int precision

BigInteger stores the integer as a big-endian array of 32 bit integers, and the sign separately as another 32-bit integer.

int signum
int[] mag

But as Muhd says, if the number can fit in a 64 bit integer, then this is used instead of a BigInteger.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)