Jump to content

Arithmetic/Rational/Java: Difference between revisions

m
Added note about simplifying zero
(Arbitrary-precision rational class for Java)
 
m (Added note about simplifying zero)
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).
 
<lang java>import java.math.BigDecimal;
Cookies help us deliver our services. By using our services, you agree to our use of cookies.