public class BigRationalextends Numberimplements Comparable<BigRational>Class BigRational provides an arbitrary precision rational number. An arbitrary precision rational number is the ratio of two arbitrary precision integers (type java.math.BigInteger). Operations are provided for exact arithmetic with rational numbers.
A rational number is said to be normalized if GCD(numerator,denominator) = 1. The methods below do not automatically normalize the rational number. Thus, the numerator and denominator tend to get larger and larger as operations are performed on the rational number. To reduce the numerator and denominator to lowest terms again, call the normalize() method. It is up to you to decide whether to normalize the rational number after each operation, or after a series of operations.
Class BigRational provides the equals() and hashCode() methods, and BigRational objects can be used as keys in hashed data structures. However, BigRational objects are mutable. If a BigRational object is used as a hash key, be sure not to change its value.
Class BigRational is not multiple thread safe.
- See Also:
- Serialized Form