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 RatNum
static RatNum
asRatNumOrNull
(Object value) int
Check if value is finite, infinite, or NaN.static int
abstract IntNum
static RatNum
static boolean
boolean
static RatNum
infinity
(int sign) Return exact "rational" infinity.boolean
isExact()
boolean
isZero()
static RatNum
static RatNum
abstract IntNum
Return this raised to an integer power.static RealNum
rationalize
(RealNum x, RealNum y) Calcaulte the simplest rational between two reals.final RatNum
rneg()
static RatNum
final RatNum
toExact()
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 RatNum
valueOf
(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 Details
-
ten_exp_9
-
-
Constructor Details
-
RatNum
public RatNum()
-
-
Method Details
-
numerator
-
denominator
-
classifyFinite
public int classifyFinite()Description copied from class:Complex
Check if value is finite, infinite, or NaN.- Overrides:
classifyFinite
in 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:Numeric
Return 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:RealNum
Convert to an exact number. Implements the Schemeinexact->exact
(for real numbers). -
toInt
Description copied from class:RealNum
Converts 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:RealNum
Converts to an exact integer, with specified rounding mode.- Overrides:
toExactInt
in classRealNum
-
rationalize
Calcaulte the simplest rational between two reals.
-