The math package provides two new classes:
BigIntegernumbers are immutable arbitrary-precision integers, which provide analogs to all of Java's primitive integer operators, and all relevant static methods from
BigIntegernumbers provide operations for modular arithmetic, GCD calculation, primality testing, prime generation, single-bit manipulation, and a few other odds and ends.
BigDecimalnumbers are immutable, arbitrary-precision signed decimal numbers, suitable for monetary calculations.
BigDecimalnumbers provide operations for basic arithmetic, scale manipulation, comparison, format conversion and hashing.
Math API Reference