Package gnu.math
Class RatNum
- All Implemented Interfaces:
Serializable,Comparable
- Direct Known Subclasses:
IntFraction,IntNum
The abstract class of rational numbers.
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic RatNumstatic RatNumasRatNumOrNull(Object value) intCheck if value is finite, infinite, or NaN.static intabstract IntNumstatic RatNumstatic booleanbooleanstatic RatNuminfinity(int sign) Return exact "rational" infinity.booleanisExact()booleanisZero()static RatNumstatic RatNumabstract IntNumReturn this raised to an integer power.static RealNumrationalize(RealNum x, RealNum y) Calcaulte the simplest rational between two reals.final RatNumrneg()static RatNumfinal RatNumtoExact()Convert to an exact number.toExactInt(int rounding_mode) Converts to an exact integer, with specified rounding mode.toInt(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, vectorPartMethods 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, toStringMethods 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, timesMethods inherited from class gnu.math.Quantity
add, compare, compareReversed, dimensions, divide, imValue, jmValue, kmValue, make, make, make, reValue, times, unitMethods inherited from class gnu.math.Numeric
add, asNumericOrNull, div_inv, floatValue, geq, grt, intValue, mul_ident, sub, toStringMethods inherited from class java.lang.Number
byteValue, shortValue
-
Field Details
-
ten_exp_9
-
-
Constructor Details
-
RatNum
public RatNum()
-
-
Method Details
-
numerator
-
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.
-
make
-
valueOf
-
asRatNumOrNull
-
isExact
public boolean isExact() -
isZero
public boolean isZero() -
rneg
-
infinity
Return exact "rational" infinity.- Parameters:
sign- either 1 or -1 for positive or negative infinity
-
compare
-
equals
-
equals
-
add
-
neg
-
times
-
divide
-
power
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
Description copied from class:RealNumConvert to an exact number. Implements the Schemeinexact->exact(for real numbers). -
toInt
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
Description copied from class:RealNumConverts to an exact integer, with specified rounding mode.- Overrides:
toExactIntin classRealNum
-
rationalize
Calcaulte the simplest rational between two reals.
-