Package gnu.math
Class RatNum
-
- All Implemented Interfaces:
Serializable,Comparable
- Direct Known Subclasses:
IntFraction,IntNum
public abstract class RatNum extends RealNum
The abstract class of rational numbers.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description RatNum()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static RatNumadd(RatNum x, RatNum y, int k)static RatNumasRatNumOrNull(Object value)intclassifyFinite()Check if value is finite, infinite, or NaN.static intcompare(RatNum x, RatNum y)abstract IntNumdenominator()static RatNumdivide(RatNum x, RatNum y)static booleanequals(RatNum x, RatNum y)booleanequals(Object obj)static RatNuminfinity(int sign)Return exact "rational" infinity.booleanisExact()booleanisZero()static RatNummake(IntNum num, IntNum den)static RatNumneg(RatNum x)abstract IntNumnumerator()Numericpower(IntNum y)Return this raised to an integer power.static RealNumrationalize(RealNum x, RealNum y)Calcaulte the simplest rational between two reals.RatNumrneg()static RatNumtimes(RatNum x, RatNum y)RatNumtoExact()Convert to an exact number.IntNumtoExactInt(int rounding_mode)Converts to an exact integer, with specified rounding mode.RealNumtoInt(int rounding_mode)Converts a real to an integer, according to a specified rounding mode.static RatNumvalueOf(BigDecimal value)-
Methods inherited from class gnu.math.RealNum
abs, add, add, angle, asBigDecimal, asRealNumOrNull, compareTo, conjugate, cos, div, divide, exp, im, isNegative, isReal, log, max, min, mul, re, sign, sin, sqrt, tan, times, toExactInt, toExactInt, toInexact, toInt, toScaledInt, toScaledInt, toScaledInt, toStringDecimal, toStringScientific, toStringScientific, toStringScientific, toStringScientific, unitQuaternion, unitVector, vectorPart
-
Methods inherited from class gnu.math.Complex
add, addReversed, colatitude, compare, compare, complexPart, divide, divReversed, equals, imMinusOne, imOne, jm, km, longitude, make, make, mulReversed, neg, neg, polar, polar, power, times, toString
-
Methods inherited from class gnu.math.Quaternion
add, compare, divide, doubleImagValue, doubleJmagValue, doubleKmagValue, doubleRealValue, doubleValue, equals, jmMinusOne, jmOne, kmMinusOne, kmOne, longValue, make, make, neg, number, polar, polar, power, times
-
Methods inherited from class gnu.math.Quantity
add, compare, compareReversed, dimensions, divide, imValue, jmValue, kmValue, make, make, make, reValue, times, unit
-
Methods inherited from class gnu.math.Numeric
add, asNumericOrNull, div_inv, floatValue, geq, grt, intValue, mul_ident, sub, toString
-
Methods inherited from class java.lang.Number
byteValue, shortValue
-
-
-
-
Field Detail
-
ten_exp_9
public static final IntNum ten_exp_9
-
-
Method Detail
-
numerator
public abstract IntNum numerator()
-
denominator
public abstract IntNum denominator()
-
classifyFinite
public int classifyFinite()
Description copied from class:ComplexCheck if value is finite, infinite, or NaN.- Overrides:
classifyFinitein classRealNum- Returns:
- 1 if finite; 0 if infinite; -1 if NaN.
-
valueOf
public static RatNum valueOf(BigDecimal value)
-
infinity
public static RatNum infinity(int sign)
Return exact "rational" infinity.- Parameters:
sign- either 1 or -1 for positive or negative infinity
-
power
public Numeric power(IntNum y)
Description copied from class:NumericReturn this raised to an integer power. Implemented by repeated squaring and multiplication. Ify < 0, returns div_inv of the result.
-
toExact
public final RatNum toExact()
Description copied from class:RealNumConvert to an exact number. Implements the Schemeinexact->exact(for real numbers).
-
toInt
public RealNum toInt(int rounding_mode)
Description copied from class:RealNumConverts a real to an integer, according to a specified rounding mode. Note an inexact argument gives an inexact result, following Scheme. See also toExactInt.
-
toExactInt
public IntNum toExactInt(int rounding_mode)
Description copied from class:RealNumConverts to an exact integer, with specified rounding mode.- Overrides:
toExactIntin classRealNum
-
-