Package gnu.math
Class IntFraction
-
- All Implemented Interfaces:
Externalizable
,Serializable
,Comparable
public class IntFraction extends RatNum implements Externalizable
Implementation of exact rational numbers a ratio of two IntNums.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description IntFraction(IntNum num, IntNum den)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Numeric
add(Object y, int k)
Return this + k * obj.Numeric
addReversed(Numeric x, int k)
Calculatex+k&this
.int
compare(Object obj)
Return an integer for which ofthis
orobj
is larger.int
compareReversed(Numeric x)
IntNum
denominator()
Numeric
div(Object y)
Numeric
divReversed(Numeric x)
double
doubleValue()
The value of the real component, as a double.boolean
isNegative()
long
longValue()
Numeric
mul(Object y)
Numeric
mulReversed(Numeric x)
Numeric
neg()
static IntFraction
neg(IntFraction x)
IntNum
numerator()
void
readExternal(ObjectInput in)
int
sign()
Return 1 if>0
; 0 if==0
; -1 if<0
; -2 ifNaN
.String
toString(int radix)
void
writeExternal(ObjectOutput out)
-
Methods inherited from class gnu.math.RatNum
add, asRatNumOrNull, classifyFinite, compare, divide, equals, equals, infinity, isExact, isZero, make, neg, power, rationalize, rneg, times, toExact, toExactInt, toInt, valueOf
-
Methods inherited from class gnu.math.RealNum
abs, add, angle, asBigDecimal, asRealNumOrNull, compareTo, conjugate, cos, divide, exp, im, isReal, log, max, min, re, 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, colatitude, compare, complexPart, divide, equals, imMinusOne, imOne, jm, km, longitude, make, make, neg, polar, polar, power, times
-
Methods inherited from class gnu.math.Quaternion
add, compare, divide, doubleImagValue, doubleJmagValue, doubleKmagValue, doubleRealValue, equals, jmMinusOne, jmOne, kmMinusOne, kmOne, make, make, neg, number, polar, polar, power, times
-
Methods inherited from class gnu.math.Quantity
add, compare, 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
-
-
-
-
Method Detail
-
denominator
public final IntNum denominator()
- Specified by:
denominator
in classRatNum
-
isNegative
public final boolean isNegative()
- Specified by:
isNegative
in classRealNum
-
sign
public final int sign()
Description copied from class:RealNum
Return 1 if>0
; 0 if==0
; -1 if<0
; -2 ifNaN
.
-
compare
public final int compare(Object obj)
Description copied from class:Numeric
Return an integer for which ofthis
orobj
is larger. Return 1 ifthis>obj
; 0 ifthis==obj
; -1 ifthis<obj
; -2 ifthis!=obj
otherwise (for example if either is NaN); -3 if not comparable (incompatible types).
-
compareReversed
public int compareReversed(Numeric x)
- Overrides:
compareReversed
in classQuantity
-
add
public Numeric add(Object y, int k)
Description copied from class:Numeric
Return this + k * obj.
-
addReversed
public Numeric addReversed(Numeric x, int k)
Description copied from class:Numeric
Calculatex+k&this
.- Overrides:
addReversed
in classComplex
-
mulReversed
public Numeric mulReversed(Numeric x)
- Overrides:
mulReversed
in classComplex
-
divReversed
public Numeric divReversed(Numeric x)
- Overrides:
divReversed
in classComplex
-
neg
public static IntFraction neg(IntFraction x)
-
longValue
public long longValue()
- Overrides:
longValue
in classQuaternion
-
doubleValue
public double doubleValue()
Description copied from class:Quantity
The value of the real component, as a double. This is relative to the unit().dims - i.e. unit()/doubleValue() is factored in.- Overrides:
doubleValue
in classQuaternion
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- Specified by:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
ClassNotFoundException
-
-