public class Rationalextends Objectimplements Comparable, SerializableClass Rational provides a 32-bit rational number. A 32-bit rational number is the ratio of two 32-bit integers (type int). Operations are provided for exact arithmetic and comparison with rational numbers.
Class Rational overrides the equals() and hashCode() methods, making it suitable for use as a key in a hashed data structure like a
. However, a Rational object is mutable. Take care not to change the value of a Rational object if it is used as a key in a hashed data structure.
Class Rational is not multiple thread safe.
- See Also:
- Serialized Form