|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectNumber
RepresentativeFractionImpl
public class RepresentativeFractionImpl
A scale where denominator = 1 / scale
.
This implementation is set up as a number - because it is.
Constructor Summary | |
---|---|
RepresentativeFractionImpl()
Default empty constructor. |
|
RepresentativeFractionImpl(long denominator)
Creates a new representative fraction from the specified denominator. |
Method Summary | |
---|---|
double |
doubleValue()
Returns the scale in a form usable for computation. |
boolean |
equals(Object object)
Compares this object with the specified value for equality. |
float |
floatValue()
Returns the scale as a float type. |
static RepresentativeFraction |
fromScale(double scale)
Creates a representative fraction from a scale as a double value. |
long |
getDenominator()
Returns the number below the line in a vulgar fraction. |
int |
hashCode()
Returns a hash value for this representative fraction. |
int |
intValue()
Returns the scale as an integer. |
long |
longValue()
Returns the scale as an integer. |
void |
setDenominator(long denominator)
Sets the denominator value. |
double |
toScale()
Deprecated. This is equivalent to doubleValue() . |
Methods inherited from class Number |
---|
byteValue, shortValue |
Methods inherited from class Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public RepresentativeFractionImpl()
public RepresentativeFractionImpl(long denominator)
denominator
- The denominator.Method Detail |
---|
public static RepresentativeFraction fromScale(double scale) throws IllegalArgumentException
double
value.
The denominator will be set to 1/scale
.
scale
- The scale as a number between 0 and 1.
IllegalArgumentException
- if the condition abs(scale) <= 1
is not meet.@Deprecated public double toScale()
doubleValue()
.
toScale
in interface RepresentativeFraction
public double doubleValue()
doubleValue
in interface RepresentativeFraction
doubleValue
in class Number
1.0 / denominator
public float floatValue()
float
type.
floatValue
in class Number
public long longValue() throws ArithmeticException
intValue()
.
longValue
in class Number
ArithmeticException
- if the denominator is 0.public int intValue() throws ArithmeticException
ArithmeticException
since infinities can not be represented by an integer.
Otherwise if the denominator is 1, then this method returns 1. Otherwise returns 0
0 since the scale is a fraction between 0 and 1, and such value can not be represented
as an integer.
intValue
in class Number
ArithmeticException
- if the denominator is 0.public long getDenominator()
getDenominator
in interface RepresentativeFraction
public void setDenominator(long denominator)
denominator
- The new denominator value.public boolean equals(Object object)
equals
in interface RepresentativeFraction
equals
in class Object
object
- The object to compare with.
true
if both objects are equal.public int hashCode()
hashCode
in interface RepresentativeFraction
hashCode
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |