Java Math Package Tutorial

HQ Ā» Java Tutorial Ā» java.math
Java Math Package Tutorial 2018-02-16T07:27:10+00:00

Package Name: java.math


The java.math package of Java APIĀ provides classes for performing arbitrary-precision integer arithmetic (BigInteger) and arbitrary-precision decimal arithmetic (BigDecimal). The BigInteger class is somewhat analogous to the primitive Integer types except that it provides arbitrary precision, thus the operations on BigIntegers do not overflow or lose precision Ā In addition to standard arithmetic operations, BigInteger provides modular arithmetic, GCD calculation, primality testing, prime generation, bit manipulation, and a few other miscellaneous operations. BigDecimal provides arbitrary-precision signed decimal numbers suitable for currency calculations and the like. BigDecimal gives the user complete control over rounding behavior, allowing the user to choose from a comprehensive set of eight rounding modes. These two classes is recommended in in dealing with calculation that involves money which requires high level precision.

java.math classes

The following are the classes that belongs to the java.math package:

  • BigDecimal
  • BigInteger
  • MathContext

Contact Info


Our Goal

JavaTutorialHQ aims to to be The Ultimate Guide on Java with hundreds of examples from basic to advance Topics.

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.