public abstract class AbstractCheckedScale0fArithmetic extends AbstractCheckedArithmetic
Scale0f, that is, for longs.| Constructor and Description |
|---|
AbstractCheckedScale0fArithmetic() |
| Modifier and Type | Method and Description |
|---|---|
long |
addLong(long uDecimal,
long lValue)
Returns an unscaled decimal whose value is the sum of the specified arguments:
(uDecimal + lValue). |
long |
fromLong(long value)
Converts the specified long value to an unscaled decimal.
|
int |
getScale()
Returns the scale
f applied to all unscaled decimal values passed to and returned by this
DecimalArithmetic. |
Scale0f |
getScaleMetrics()
Returns the scale metrics associated with this decimal arithmetic object.
|
long |
multiply(long uDecimal1,
long uDecimal2)
Returns an unscaled decimal whose value is the product of the specified arguments:
(uDecimal1 * uDecimal2). |
long |
one()
Returns the unscaled decimal for the decimal value
1. |
long |
square(long uDecimal)
Returns an unscaled decimal whose value is the square of the specified argument: uDecimal2.
|
long |
subtractLong(long uDecimal,
long lValue)
Returns an unscaled decimal whose value is the difference of the specified arguments:
(uDecimal - lValue)
. |
long |
toLong(long uDecimal)
Converts the specified unscaled decimal value into a long value and returns it.
|
String |
toString(long uDecimal)
Converts the specified unscaled decimal value into a
String and returns it. |
void |
toString(long uDecimal,
Appendable appendable)
Converts the specified unscaled decimal value into a
String and appends the string to the
appendable. |
abs, add, getOverflowMode, getTruncationPolicy, multiplyByLong, negate, subtractcompare, compareToUnscaled, deriveArithmetic, deriveArithmetic, deriveArithmetic, deriveArithmetic, deriveArithmetic, fromBigInteger, signum, toBigDecimal, toBigDecimalclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddUnscaled, avg, divide, divideByLong, divideByPowerOf10, divideByUnscaled, fromBigDecimal, fromDouble, fromFloat, fromUnscaled, getRoundingMode, invert, multiplyByPowerOf10, multiplyByUnscaled, parse, parse, pow, round, shiftLeft, shiftRight, sqrt, subtractUnscaled, toDouble, toFloat, toUnscaledpublic AbstractCheckedScale0fArithmetic()
public final Scale0f getScaleMetrics()
DecimalArithmeticpublic final int getScale()
DecimalArithmeticf applied to all unscaled decimal values passed to and returned by this
DecimalArithmetic. Corresponds to the number of digits to the right of the decimal point (cannot be
negative).
A given Decimal value multiplied with 10f results in an unscaled long value.
Conversely, a Decimal value d can be computed from the unscaled value u as
d = u*10-f.
f applied to unscaled decimal values within this DecimalArithmetic
objectScaleMetrics.getScale()public final long one()
DecimalArithmetic1. One is the value 10scale which
is also the multiplier used to get the unscaled decimal from the true decimal value.public final long addLong(long uDecimal, long lValue)
DecimalArithmetic(uDecimal + lValue).
Mathematically the method calculates (uDecimal + lValue * 10scale) avoiding information loss due to overflow of intermediary results.
uDecimal - unscaled decimal value to be addedlValue - long value to be addedpublic final long subtractLong(long uDecimal, long lValue)
DecimalArithmetic(uDecimal - lValue)
.
Mathematically the method calculates (uDecimal - lValue * 10scale) avoiding information loss due to overflow of intermediary results.
uDecimal - unscaled decimal value to subtract fromlValue - long value to subtractpublic final long multiply(long uDecimal1, long uDecimal2)
DecimalArithmetic(uDecimal1 * uDecimal2). If rounding must be performed, this arithmetic's rounding mode is applied.
Mathematically the method calculates round((uDecimal1 * uDecimal2) * 10-scale) avoiding information loss due to overflow of intermediary results.
uDecimal1 - first unscaled decimal value to be multiplieduDecimal2 - second unscaled decimal value to be multipliedround(uDecimal1 * uDecimal2)public final long square(long uDecimal)
DecimalArithmeticrounding mode is applied.
Mathematically the method calculates round((uDecimal * uDecimal) * 10-scale) avoiding information loss due to overflow of intermediary results.
uDecimal - the unscaled decimal value to be squaredround(uDecimal * uDecimal)public final long fromLong(long value)
DecimalArithmeticscale.value - the value to convertpublic final long toLong(long uDecimal)
DecimalArithmeticrounding mode is applied if rounding is necessary.uDecimal - the unscaled decimal value to convert into a long valueuDecimal value converted into a long value, possibly rounded or truncatedpublic final String toString(long uDecimal)
DecimalArithmeticString and returns it. If the scale is zero, the conversion is identical to Long.toString(long). For all other scales a value with
exactly scale fraction digits is returned even if some trailing fraction digits are zero.
Note: this operation is not strictly garbage free since the result value is allocated; however no
temporary objects other than the result are allocated during the conversion (internally a ThreadLocal
StringBuilder object is used to construct the string value, which may become garbage if the thread
becomes garbage).
uDecimal - the unscaled decimal value to convert into a StringuDecimal value as into a Stringpublic final void toString(long uDecimal, Appendable appendable) throws IOException
DecimalArithmeticString and appends the string to the
appendable.
If the scale is zero, the conversion into a string is identical to
Long.toString(long). For all other scales a string value with exactly scale fraction digits is
created even if some trailing fraction digits are zero.
Note: this operation is not strictly garbage free since internally, a ThreadLocal string builder
is used to construct the string. The ThreadLocal value may become garbage if the thread becomes garbage.
uDecimal - the unscaled decimal value to convert into a Stringappendable - the appendable to which the string representation of the unscaled decimal value is to be appendedIOException - If an I/O error occurs when appending to appendable