Arithmetic/Rational/Java: Difference between revisions

Content added Content deleted
m (Extended Number and implemented Comparable as suggested by taitale on reddit)
No edit summary
Line 1: Line 1:
Modeled after BigInteger/BigDecimal. Instances of this class are immutable, and simplified upon construction. The returned numerator() and denominator() are never negative; the sign can be retrieved via signum(). The numerator for zero is always 1 (e.g. 0/5 is simplified to 0/1), and signed zeros are not supported (e.g. 0/-1 is simplified to 0/1).
Modeled after BigInteger/BigDecimal. Instances of this class are immutable, and simplified upon construction. The returned numerator() and denominator() are never negative; the sign can be retrieved via signum(). The denominator for zero is always 1 (e.g. 0/5 is simplified to 0/1), and signed zeros are not supported (e.g. 0/-1 is simplified to 0/1).


<lang java>import java.math.BigDecimal;
<lang java>import java.math.BigDecimal;