|
ModeShape Distribution 3.0.0.Beta4 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.modeshape.common.math.FloatOperations
@Immutable public class FloatOperations
The math operations
for float numbers.
Constructor Summary | |
---|---|
FloatOperations()
|
Method Summary | |
---|---|
Float |
add(Float value1,
Float value2)
Add the two operands and return the sum. |
BigDecimal |
asBigDecimal(Float value)
Create a BigDecimal representation of the supplied value. |
int |
compare(Float value1,
Float value2)
Compare the two operands and return an integer that describes whether the first value is larger, smaller or the same as the second value. |
Float |
create(double value)
Convert the double representation into the natural object representation. |
Float |
create(int value)
Convert the integer representation into the natural object representation. |
Float |
create(long value)
Convert the long representation into the natural object representation. |
Float |
createZeroValue()
Create the object form of the "zero value". |
double |
divide(Float value1,
Float value2)
Divide the first operand by the second, and return the result. |
double |
doubleValue(Float value)
Convert the value to a double. |
float |
floatValue(Float value)
Convert the value to a float. |
Float |
fromBigDecimal(BigDecimal value)
Convert the BigDecimal representation into the natural object representation. |
Comparator<Float> |
getComparator()
Return a Comparator for this operand class . |
int |
getExponentInScientificNotation(Float value)
Get the exponent if the number were written in exponential form. |
Class<Float> |
getOperandClass()
Return the class that these operations operate upon. |
Float |
increment(Float value)
Increment the supplied operand by 1. |
int |
intValue(Float value)
Convert the value to an integer. |
Float |
keepSignificantFigures(Float value,
int numSigFigs)
|
long |
longValue(Float value)
Convert the value to a long integer. |
Float |
maximum(Float value1,
Float value2)
Compare the two operands and return the one that is larger. |
Float |
minimum(Float value1,
Float value2)
Compare the two operands and return the one that is smaller. |
Float |
multiply(Float value1,
Float value2)
Multiply the two operands and return the product. |
Float |
negate(Float value)
Negate the supplied operand. |
Float |
random(Float minimum,
Float maximum,
Random rng)
Generate a random instance within the specified range. |
Float |
roundDown(Float value,
int decimalShift)
Round down the supplied value to the desired scale. |
Float |
roundUp(Float value,
int decimalShift)
Round up the supplied value to the desired scale. |
short |
shortValue(Float value)
Convert the value to a short. |
double |
sqrt(Float value)
Return the square root of the supplied operand. |
Float |
subtract(Float value1,
Float value2)
Subtract the second operand from the first, and return the difference. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.util.Comparator |
---|
equals |
Constructor Detail |
---|
public FloatOperations()
Method Detail |
---|
public Class<Float> getOperandClass()
MathOperations
getOperandClass
in interface MathOperations<Float>
public Float add(Float value1, Float value2)
MathOperations
zero value
is used in place of any operand that is
null.
add
in interface MathOperations<Float>
value1
- the first operandvalue2
- the second operand
public Float subtract(Float value1, Float value2)
MathOperations
zero value
is used in
place of any operand that is null.
subtract
in interface MathOperations<Float>
value1
- the first operandvalue2
- the second operand
public Float multiply(Float value1, Float value2)
MathOperations
zero value
is used in place of any operand
that is null.
multiply
in interface MathOperations<Float>
value1
- the first operandvalue2
- the second operand
public double divide(Float value1, Float value2)
MathOperations
zero value
is used in place
of any operand that is null.
divide
in interface MathOperations<Float>
value1
- the first operandvalue2
- the second operand
public Float negate(Float value)
MathOperations
zero value
is used in place of any operand that is null.
negate
in interface MathOperations<Float>
value
- the value that is to be negated
public Float increment(Float value)
MathOperations
operand class
. The zero value
is used in place of any operand that is
null.
increment
in interface MathOperations<Float>
value
- the value that is to be incremented
public Float maximum(Float value1, Float value2)
MathOperations
maximum
in interface MathOperations<Float>
value1
- the first operandvalue2
- the second operand
public Float minimum(Float value1, Float value2)
MathOperations
minimum
in interface MathOperations<Float>
value1
- the first operandvalue2
- the second operand
public int compare(Float value1, Float value2)
MathOperations
Comparable
. The zero value
is used
in place of any operand that is null.
compare
in interface Comparator<Float>
compare
in interface MathOperations<Float>
value1
- the first operandvalue2
- the second operand
public BigDecimal asBigDecimal(Float value)
MathOperations
BigDecimal
representation of the supplied value.
asBigDecimal
in interface MathOperations<Float>
value
- the value that is to be converted to a BigDecimal
value
is nullpublic Float fromBigDecimal(BigDecimal value)
MathOperations
BigDecimal
representation into the natural object representation. This may result in loss of some data
(e.g., converting a decimal to an integer results in the loss of the fractional part of the number).
fromBigDecimal
in interface MathOperations<Float>
value
- the BigDecimal value
value
is nullpublic Float createZeroValue()
MathOperations
createZeroValue
in interface MathOperations<Float>
public Float create(int value)
MathOperations
create
in interface MathOperations<Float>
value
- the integer value
public Float create(long value)
MathOperations
create
in interface MathOperations<Float>
value
- the long value
public Float create(double value)
MathOperations
create
in interface MathOperations<Float>
value
- the double value
public double sqrt(Float value)
MathOperations
sqrt
in interface MathOperations<Float>
value
- the value whose root is to be found; may not be null or 0
public Comparator<Float> getComparator()
MathOperations
Comparator
for this operand class
. The implementation is free to
return the same comparator instance from multiple invocations of this method.
getComparator
in interface MathOperations<Float>
public Float random(Float minimum, Float maximum, Random rng)
MathOperations
random
in interface MathOperations<Float>
minimum
- the minimum value, or null if the zero-value
should be used for the minimummaximum
- the maximum value, or null if the zero-value
should be used for the maximumrng
- the random number generator to use
operand class
placed within the desired range using a random
distribution, or null if this class does not support generating random instancespublic double doubleValue(Float value)
MathOperations
operand class
.
doubleValue
in interface MathOperations<Float>
value
- the value
public float floatValue(Float value)
MathOperations
operand
class
.
floatValue
in interface MathOperations<Float>
value
- the value
public int intValue(Float value)
MathOperations
operand class
.
intValue
in interface MathOperations<Float>
value
- the value
public long longValue(Float value)
MathOperations
operand class
.
longValue
in interface MathOperations<Float>
value
- the value
public short shortValue(Float value)
MathOperations
operand
class
.
shortValue
in interface MathOperations<Float>
value
- the value
public int getExponentInScientificNotation(Float value)
MathOperations
getExponentInScientificNotation
in interface MathOperations<Float>
value
- the value
public Float roundUp(Float value, int decimalShift)
MathOperations
decimalShift
places, rounding, and then shifting the decimal point of the rounded value by
-decimalShift
For example, consider the number 10.000354. This can be rounded to 10.0004 by calling this method and supplying the value and an "exponentToKeep" value of -4.
roundUp
in interface MathOperations<Float>
value
- the value to be roundeddecimalShift
- the number of places the decimal point should be shifted before rounding
public Float roundDown(Float value, int decimalShift)
MathOperations
decimalShift
places, rounding, and then shifting the decimal point of the rounded value by
-decimalShift
For example, consider the number 10.000354. This can be rounded to 10.0003 by calling this method and supplying the value and an "exponentToKeep" value of -4.
roundDown
in interface MathOperations<Float>
value
- the value to be roundeddecimalShift
- the number of places the decimal point should be shifted before rounding
public Float keepSignificantFigures(Float value, int numSigFigs)
keepSignificantFigures
in interface MathOperations<Float>
|
ModeShape Distribution 3.0.0.Beta4 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |