public enum Scale12f extends Enum<Scale12f> implements ScaleMetrics
scale
12 and
scale factor
1000000000000.Enum Constant and Description |
---|
INSTANCE
The singleton instance for scale 12.
|
Modifier and Type | Field and Description |
---|---|
static int |
SCALE
The scale value
12 . |
static long |
SCALE_FACTOR
The scale factor
1012 . |
Modifier and Type | Method and Description |
---|---|
long |
divideByScaleFactor(long dividend)
Returns
dividend/scaleFactor . |
long |
divideUnsignedByScaleFactor(long unsignedDividend)
Returns
unsignedDividend/scaleFactor using unsigned division. |
DecimalArithmetic |
getArithmetic(RoundingMode roundingMode)
Returns the arithmetic for this scale that performs all operations with the specified
roundingMode and
without overflow checks. |
DecimalArithmetic |
getArithmetic(TruncationPolicy truncationPolicy)
Returns the arithmetic for this scale that performs all operations with the specified
truncationPolicy . |
DecimalArithmetic |
getCheckedArithmetic(RoundingMode roundingMode)
Returns the arithmetic for this scale that performs all operations with the specified
roundingMode and
with overflow checks. |
DecimalArithmetic |
getDefaultArithmetic()
Returns the default arithmetic for this scale performing unchecked operations with rounding mode
HALF_UP . |
DecimalArithmetic |
getDefaultCheckedArithmetic()
Returns the default arithmetic for this scale performing checked operations with rounding mode
HALF_UP . |
long |
getMaxIntegerValue()
Returns the largest integer value that can be represented using this scale.
|
long |
getMinIntegerValue()
Returns the smallest integer value that can be represented using this scale.
|
DecimalArithmetic |
getRoundingDownArithmetic()
Returns the arithmetic for this scale performing unchecked operations with rounding mode
DOWN . |
DecimalArithmetic |
getRoundingFloorArithmetic()
Returns the arithmetic for this scale performing unchecked operations with rounding mode
FLOOR . |
DecimalArithmetic |
getRoundingHalfEvenArithmetic()
Returns the arithmetic for this scale performing unchecked operations with rounding mode
HALF_EVEN . |
DecimalArithmetic |
getRoundingUnnecessaryArithmetic()
Returns the arithmetic for this scale performing unchecked operations with rounding mode
UNNECESSARY . |
int |
getScale()
Returns the scale, the number of fraction digits to the right of the decimal point of a
Decimal value. |
long |
getScaleFactor()
Returns the scale factor, which is 10f where
f stands for the scale . |
BigDecimal |
getScaleFactorAsBigDecimal()
Returns the
scale factor as a BigDecimal value with scale zero. |
BigInteger |
getScaleFactorAsBigInteger()
Returns the
scale factor as a BigInteger value. |
int |
getScaleFactorNumberOfLeadingZeros()
Returns the number of leading zeros of the scale factor
|
boolean |
isValidIntegerValue(long value)
Returns true if the specified integer
value can be represented using this scale. |
long |
moduloByScaleFactor(long dividend)
Returns
dividend % scaleFactor also known as reminder. |
long |
mulhiByScaleFactor(int factor)
Returns
factor*high32(scaleFactor) where high32 refers to the high 32 bits of the factor. |
long |
mulloByScaleFactor(int factor)
Returns
factor*low32(scaleFactor) where low32 refers to the low 32 bits of the factor. |
long |
multiplyByScaleFactor(long factor)
Returns
factor*scaleFactor . |
long |
multiplyByScaleFactorExact(long factor)
Returns
factor*scaleFactor , checking for lost information. |
String |
toString() |
String |
toString(long value)
Returns the string representation of the specified
value applying this metric's scale. |
static Scale12f |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static Scale12f[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final int SCALE
12
.public static final long SCALE_FACTOR
1012
.public static Scale12f[] values()
for (Scale12f c : Scale12f.values()) System.out.println(c);
public static Scale12f valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic final int getScale()
ScaleMetrics
Decimal
value.getScale
in interface ScaleMetrics
public final long getScaleFactor()
ScaleMetrics
f
stands for the scale
.getScaleFactor
in interface ScaleMetrics
public final int getScaleFactorNumberOfLeadingZeros()
ScaleMetrics
getScaleFactorNumberOfLeadingZeros
in interface ScaleMetrics
Long.numberOfLeadingZeros(long)
applied to the scale factorpublic final long multiplyByScaleFactor(long factor)
ScaleMetrics
factor*scaleFactor
.multiplyByScaleFactor
in interface ScaleMetrics
factor
- the factorfactor*scaleFactor
public final BigInteger getScaleFactorAsBigInteger()
ScaleMetrics
scale factor
as a BigInteger
value.getScaleFactorAsBigInteger
in interface ScaleMetrics
public final BigDecimal getScaleFactorAsBigDecimal()
ScaleMetrics
scale factor
as a BigDecimal
value with scale zero.getScaleFactorAsBigDecimal
in interface ScaleMetrics
public final long getMaxIntegerValue()
ScaleMetrics
getMaxIntegerValue
in interface ScaleMetrics
Long.MAX_VALUE / scaleFactor
public final long getMinIntegerValue()
ScaleMetrics
getMinIntegerValue
in interface ScaleMetrics
Long.MIN_VALUE / scaleFactor
public final boolean isValidIntegerValue(long value)
ScaleMetrics
value
can be represented using this scale.isValidIntegerValue
in interface ScaleMetrics
value
- the value to test(Long.MIN_VALUE / scaleFactor) <= value <= (Long.MAX_VALUE / scaleFactor)
public final long multiplyByScaleFactorExact(long factor)
ScaleMetrics
factor*scaleFactor
, checking for lost information. If the result is out of the range of the
long
type, then an ArithmeticException
is thrown.multiplyByScaleFactorExact
in interface ScaleMetrics
factor
- the factorfactor*scaleFactor
public final long mulloByScaleFactor(int factor)
ScaleMetrics
factor*low32(scaleFactor)
where low32 refers to the low 32 bits of the factor.mulloByScaleFactor
in interface ScaleMetrics
factor
- the factorfactor*low32(scaleFactor)
public final long mulhiByScaleFactor(int factor)
ScaleMetrics
factor*high32(scaleFactor)
where high32 refers to the high 32 bits of the factor.mulhiByScaleFactor
in interface ScaleMetrics
factor
- the factorfactor*high32(scaleFactor)
public final long divideByScaleFactor(long dividend)
ScaleMetrics
dividend/scaleFactor
.divideByScaleFactor
in interface ScaleMetrics
dividend
- the dividenddividend/scaleFactor
public final long divideUnsignedByScaleFactor(long unsignedDividend)
ScaleMetrics
unsignedDividend/scaleFactor
using unsigned division.divideUnsignedByScaleFactor
in interface ScaleMetrics
unsignedDividend
- the unsigned dividendunsignedDividend/scaleFactor
public final long moduloByScaleFactor(long dividend)
ScaleMetrics
dividend % scaleFactor
also known as reminder.moduloByScaleFactor
in interface ScaleMetrics
dividend
- the dividenddividend % scaleFactor
public final String toString(long value)
ScaleMetrics
value
applying this metric's scale.toString
in interface ScaleMetrics
value
- the unscaled decimal to convert to a stringDecimalArithmetic.toString(long)
public final DecimalArithmetic getDefaultArithmetic()
ScaleMetrics
HALF_UP
.getDefaultArithmetic
in interface ScaleMetrics
public final DecimalArithmetic getDefaultCheckedArithmetic()
ScaleMetrics
HALF_UP
.getDefaultCheckedArithmetic
in interface ScaleMetrics
public final DecimalArithmetic getRoundingDownArithmetic()
ScaleMetrics
DOWN
.getRoundingDownArithmetic
in interface ScaleMetrics
public final DecimalArithmetic getRoundingFloorArithmetic()
ScaleMetrics
FLOOR
.getRoundingFloorArithmetic
in interface ScaleMetrics
public final DecimalArithmetic getRoundingHalfEvenArithmetic()
ScaleMetrics
HALF_EVEN
.getRoundingHalfEvenArithmetic
in interface ScaleMetrics
public final DecimalArithmetic getRoundingUnnecessaryArithmetic()
ScaleMetrics
UNNECESSARY
.getRoundingUnnecessaryArithmetic
in interface ScaleMetrics
public final DecimalArithmetic getArithmetic(RoundingMode roundingMode)
ScaleMetrics
roundingMode
and
without overflow checks.getArithmetic
in interface ScaleMetrics
roundingMode
- the rounding mode used by the returned arithmeticpublic final DecimalArithmetic getCheckedArithmetic(RoundingMode roundingMode)
ScaleMetrics
roundingMode
and
with overflow checks.getCheckedArithmetic
in interface ScaleMetrics
roundingMode
- the rounding mode used by the returned arithmeticpublic final DecimalArithmetic getArithmetic(TruncationPolicy truncationPolicy)
ScaleMetrics
truncationPolicy
.getArithmetic
in interface ScaleMetrics
truncationPolicy
- the truncation policy used by the returned arithmetic