@Immutable public class ShortOperations extends Object implements MathOperations<Short>, Comparator<Short>
math operations
for short numbers.Constructor and Description |
---|
ShortOperations() |
Modifier and Type | Method and Description |
---|---|
Short |
add(Short value1,
Short value2)
Add the two operands and return the sum.
|
BigDecimal |
asBigDecimal(Short value)
Create a
BigDecimal representation of the supplied value. |
int |
compare(Short value1,
Short 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.
|
Short |
create(double value)
Convert the double representation into the natural object representation.
|
Short |
create(int value)
Convert the integer representation into the natural object representation.
|
Short |
create(long value)
Convert the long representation into the natural object representation.
|
Short |
createZeroValue()
Create the object form of the "zero value".
|
double |
divide(Short value1,
Short value2)
Divide the first operand by the second, and return the result.
|
double |
doubleValue(Short value)
Convert the value to a double.
|
float |
floatValue(Short value)
Convert the value to a float.
|
Short |
fromBigDecimal(BigDecimal value)
Convert the
BigDecimal representation into the natural object representation. |
Comparator<Short> |
getComparator()
Return a
Comparator for this operand class . |
int |
getExponentInScientificNotation(Short value)
Get the exponent if the number were written in exponential form.
|
Class<Short> |
getOperandClass()
Return the class that these operations operate upon.
|
Short |
increment(Short value)
Increment the supplied operand by 1.
|
int |
intValue(Short value)
Convert the value to an integer.
|
Short |
keepSignificantFigures(Short value,
int numSigFigs) |
long |
longValue(Short value)
Convert the value to a long integer.
|
Short |
maximum(Short value1,
Short value2)
Compare the two operands and return the one that is larger.
|
Short |
minimum(Short value1,
Short value2)
Compare the two operands and return the one that is smaller.
|
Short |
multiply(Short value1,
Short value2)
Multiply the two operands and return the product.
|
Short |
negate(Short value)
Negate the supplied operand.
|
Short |
random(Short minimum,
Short maximum,
Random rng)
Generate a random instance within the specified range.
|
Short |
roundDown(Short value,
int decimalShift)
Round down the supplied value to the desired scale.
|
Short |
roundUp(Short value,
int decimalShift)
Round up the supplied value to the desired scale.
|
short |
shortValue(Short value)
Convert the value to a short.
|
double |
sqrt(Short value)
Return the square root of the supplied operand.
|
Short |
subtract(Short value1,
Short value2)
Subtract the second operand from the first, and return the difference.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
comparing, comparing, comparingDouble, comparingInt, comparingLong, equals, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
public Class<Short> getOperandClass()
MathOperations
getOperandClass
in interface MathOperations<Short>
public Short add(Short value1, Short value2)
MathOperations
zero value
is used in place of any operand that is
null.add
in interface MathOperations<Short>
value1
- the first operandvalue2
- the second operandpublic Short subtract(Short value1, Short value2)
MathOperations
zero value
is used in
place of any operand that is null.subtract
in interface MathOperations<Short>
value1
- the first operandvalue2
- the second operandpublic Short multiply(Short value1, Short value2)
MathOperations
zero value
is used in place of any operand
that is null.multiply
in interface MathOperations<Short>
value1
- the first operandvalue2
- the second operandpublic double divide(Short value1, Short value2)
MathOperations
zero value
is used in place
of any operand that is null.divide
in interface MathOperations<Short>
value1
- the first operandvalue2
- the second operandpublic Short negate(Short value)
MathOperations
zero value
is used in place of any operand that is null.negate
in interface MathOperations<Short>
value
- the value that is to be negatedpublic Short increment(Short value)
MathOperations
operand class
. The zero value
is used in place of any operand that is
null.increment
in interface MathOperations<Short>
value
- the value that is to be incrementedpublic Short maximum(Short value1, Short value2)
MathOperations
maximum
in interface MathOperations<Short>
value1
- the first operandvalue2
- the second operandpublic Short minimum(Short value1, Short value2)
MathOperations
minimum
in interface MathOperations<Short>
value1
- the first operandvalue2
- the second operandpublic int compare(Short value1, Short value2)
MathOperations
Comparable
. The zero value
is used
in place of any operand that is null.compare
in interface Comparator<Short>
compare
in interface MathOperations<Short>
value1
- the first operandvalue2
- the second operandpublic BigDecimal asBigDecimal(Short value)
MathOperations
BigDecimal
representation of the supplied value.asBigDecimal
in interface MathOperations<Short>
value
- the value that is to be converted to a BigDecimalvalue
is nullpublic Short 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<Short>
value
- the BigDecimal valuevalue
is nullpublic Short createZeroValue()
MathOperations
createZeroValue
in interface MathOperations<Short>
public Short create(int value)
MathOperations
create
in interface MathOperations<Short>
value
- the integer valuepublic Short create(long value)
MathOperations
create
in interface MathOperations<Short>
value
- the long valuepublic Short create(double value)
MathOperations
create
in interface MathOperations<Short>
value
- the double valuepublic double sqrt(Short value)
MathOperations
sqrt
in interface MathOperations<Short>
value
- the value whose root is to be found; may not be null or 0public Comparator<Short> 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<Short>
public Short random(Short minimum, Short maximum, Random rng)
MathOperations
random
in interface MathOperations<Short>
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 useoperand class
placed within the desired range using a random
distribution, or null if this class does not support generating random instancespublic double doubleValue(Short value)
MathOperations
operand class
.doubleValue
in interface MathOperations<Short>
value
- the valuepublic float floatValue(Short value)
MathOperations
operand
class
.floatValue
in interface MathOperations<Short>
value
- the valuepublic int intValue(Short value)
MathOperations
operand class
.intValue
in interface MathOperations<Short>
value
- the valuepublic long longValue(Short value)
MathOperations
operand class
.longValue
in interface MathOperations<Short>
value
- the valuepublic short shortValue(Short value)
MathOperations
operand
class
.shortValue
in interface MathOperations<Short>
value
- the valuepublic int getExponentInScientificNotation(Short value)
MathOperations
getExponentInScientificNotation
in interface MathOperations<Short>
value
- the valuepublic Short roundUp(Short 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<Short>
value
- the value to be roundeddecimalShift
- the number of places the decimal point should be shifted before roundingpublic Short roundDown(Short 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<Short>
value
- the value to be roundeddecimalShift
- the number of places the decimal point should be shifted before roundingpublic Short keepSignificantFigures(Short value, int numSigFigs)
keepSignificantFigures
in interface MathOperations<Short>
Copyright © 2008–2016 JBoss, a division of Red Hat. All rights reserved.