Top Description Fields Constructors Methods
com.ibm.icu.impl.number

public abstract Class DecimalQuantity_AbstractBCD

extends Object
implements DecimalQuantity
Class Inheritance
All Implemented Interfaces
com.ibm.icu.impl.number.DecimalQuantity, com.ibm.icu.text.PluralRules.IFixedDecimal
Known Direct Subclasses
com.ibm.icu.impl.number.DecimalQuantity_DualStorageBCD
Imports
java.math.BigDecimal, .BigInteger, .MathContext, java.text.FieldPosition, com.ibm.icu.impl.StandardPlural, .Utility, com.ibm.icu.impl.number.Modifier.Signum, com.ibm.icu.text.PluralRules, .PluralRules.Operand, .UFieldPosition

Deprecated

as a consequence of DecimalQuantity being deprecated. See corresponding docs for further information.

Represents numbers and digit display properties using Binary Coded Decimal (BCD).

Field Summary

Modifier and TypeField and Description
private static final double[]
public boolean
explicitExactDouble

Whether this DecimalQuantity_DualStorageBCD has been explicitly converted to an exact double.

protected int
exponent

The value of the (suppressed) exponent after the number has been put into a notation with exponents (ex: compact, scientific).

protected byte
flags

A bitmask of properties relating to the number represented by this object.

protected static final int
pack-priv static final byte[]
protected boolean
isApproximate

Whether the value in the BCD comes from the double fast path without having been rounded to ensure correctness

protected int
protected static final int
protected static final int
protected int
origDelta

The change in magnitude relative to the original double.

protected double
origDouble

The original number provided by the user and which is represented in BCD.

protected int
precision

The number of digits in the BCD.

protected int
protected int
scale

The power of ten corresponding to the least significant digit in the BCD.

private static final int
private static final int

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private void
private void
private void
_setToDoubleFast(double n)

Uses double multiplication and division to get the number into integer space before converting to digits.

private void
_setToInt(int n)

private void
_setToLong(long n)

public void
adjustExponent(int
The value to adjust the exponent by.
delta
)

Implements com.ibm.icu.impl.number.DecimalQuantity.adjustExponent.

Adjusts the value for the (suppressed) exponent stored when using notation with exponents (ex: compact, scientific).
public void
adjustMagnitude(int
The number of magnitudes of ten to change by.
delta
)

Implements com.ibm.icu.impl.number.DecimalQuantity.adjustMagnitude.

Scales the number by a power of ten.
public void
appendDigit(byte
The digit to append.
value
,
int
The number of zeros to append before the digit. For example, if the value in this instance starts as 12.3, and you append a 4 with 1 leading zero, the value becomes 12.304.
leadingZeros
,
boolean
If true, increase the magnitude of existing digits to make room for the new digit. If false, append to the end like a fraction digit. If true, there must not be any fraction digits already in the number.
appendAsInteger
)

Deprecated This API is ICU internal only.
Appends a digit, optionally with one or more leading zeros, to the end of the value represented by this DecimalQuantity.
public void
applyMaxInteger(int
The maximum number of integer digits.
maxInt
)

Implements com.ibm.icu.impl.number.DecimalQuantity.applyMaxInteger.

Truncates digits from the upper magnitude of the number in order to satisfy the specified maximum number of integer digits.
protected abstract BigDecimal

Returns:

A BigDecimal representation of the internal BCD.
bcdToBigDecimal
()

Returns a BigDecimal encoding the internal BCD value.

public DecimalQuantity_AbstractBCD
clear()

Deprecated as a consequence of DecimalQuantity_AbstractBCD being deprecated.
protected abstract void
compact()

Removes trailing zeros from the BCD (adjusting the scale as required) and then computes the precision.

private void
convertToAccurateDouble()

Uses Double.toString() to obtain an exact accurate representation of the double, overwriting it into the BCD.

protected abstract void
copyBcdFrom(DecimalQuantity _other)

Deprecated as a consequence of DecimalQuantity being deprecated.
public void
copyFrom(DecimalQuantity
The instance to copy from.
_other
)

Implements com.ibm.icu.impl.number.DecimalQuantity.copyFrom.

Deprecated as a consequence of DecimalQuantity being deprecated.
Sets this instance to be equal to another instance.
public boolean
equals(Object
the reference object with which to compare.
other
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public boolean
fitsInLong()

Returns whether or not a Long can fully represent the value stored in this DecimalQuantity.

private int
private int
public byte
getDigit(int
The magnitude of the digit.
magnitude
)

Implements com.ibm.icu.impl.number.DecimalQuantity.getDigit.

Gets the digit at the specified magnitude.
protected abstract byte

Returns:

The digit at the specified location.
getDigitPos
(int
The position of the digit to pop, counted in BCD units from the least significant digit. If outside the range supported by the implementation, zero is returned.
position
)

Returns a single digit from the BCD list.

public int
public int
getLowerDisplayMagnitude()

Implements com.ibm.icu.impl.number.DecimalQuantity.getLowerDisplayMagnitude.

Gets the smallest power of ten that needs to be displayed.
public int
public double
getPluralOperand(PluralRules.Operand operand)

Implements com.ibm.icu.text.PluralRules.IFixedDecimal.getPluralOperand.

Deprecated as a consequence of PluralRules.Operand being deprecated.
Returns the value corresponding to the specified operand (n, i, f, t, v, or w).
public long
getPositionFingerprint()

Implements com.ibm.icu.impl.number.DecimalQuantity.getPositionFingerprint.

This method is for internal testing only.
public StandardPlural
getStandardPlural(PluralRules
A PluralRules object representing the set of rules.
rules
)

Implements com.ibm.icu.impl.number.DecimalQuantity.getStandardPlural.

Computes the plural form for this number based on the specified set of rules.
public int
getUpperDisplayMagnitude()

Implements com.ibm.icu.impl.number.DecimalQuantity.getUpperDisplayMagnitude.

Gets the largest power of ten that needs to be displayed.
public boolean
isHasIntegerValue()

Implements com.ibm.icu.text.PluralRules.IFixedDecimal.isHasIntegerValue.

Whether the number has no nonzero fraction digits.
public boolean
public boolean
public boolean
public boolean
public void
multiplyBy(BigDecimal
The value by which to multiply.
multiplicand
)

Implements com.ibm.icu.impl.number.DecimalQuantity.multiplyBy.

Multiply the internal value.
public void
negate()

Implements com.ibm.icu.impl.number.DecimalQuantity.negate.

Flips the sign from positive to negative and back.
protected abstract void
popFromLeft(int numDigits)

Directly removes digits from the front of the BCD list.

public void
populateUFieldPosition(FieldPosition
The UFieldPosition to populate.
fp
)

Implements com.ibm.icu.impl.number.DecimalQuantity.populateUFieldPosition.

If the given FieldPosition is a UFieldPosition, populates it with the fraction length and fraction long value.
protected abstract void
readBigIntegerToBcd(BigInteger
The value to consume.
input
)

Sets the internal BCD state to represent the value in the given BigInteger.

protected abstract void
readIntToBcd(int
The value to consume.
input
)

Sets the internal BCD state to represent the value in the given int.

protected abstract void
readLongToBcd(long
The value to consume.
input
)

Sets the internal BCD state to represent the value in the given long.

public void
resetExponent()

Implements com.ibm.icu.impl.number.DecimalQuantity.resetExponent.

Resets the DecimalQuantity to the value before adjustMagnitude and adjustExponent.
public void
roundToIncrement(BigDecimal
The increment to which to round.
roundingIncrement
,
MathContext
The MathContext to use if rounding is necessary. Undefined behavior if null.
mathContext
)

Implements com.ibm.icu.impl.number.DecimalQuantity.roundToIncrement.

Rounds the number to a specified interval, such as 0.05.
public void
roundToInfinity()

Implements com.ibm.icu.impl.number.DecimalQuantity.roundToInfinity.

Rounds the number to an infinite number of decimal points.
public void
roundToMagnitude(int
The power of ten to which to round. For example, a value of -2 will round to 2 decimal places.
magnitude
,
MathContext
The MathContext to use if rounding is necessary. Undefined behavior if null.
mathContext
)

Implements com.ibm.icu.impl.number.DecimalQuantity.roundToMagnitude.

Rounds the number to a specified magnitude (power of ten).
private void
roundToMagnitude(int magnitude, MathContext mathContext, boolean nickel)

public void
roundToNickel(int
The magnitude at which the digit should become either 0 or 5.
magnitude
,
MathContext
Rounding strategy.
mathContext
)

Implements com.ibm.icu.impl.number.DecimalQuantity.roundToNickel.

Rounds the number to the nearest multiple of 5 at the specified magnitude.
private static int
safeSubtract(int a, int b)

protected abstract void
setBcdToZero()

Sets the internal representation to zero.

protected abstract void
setDigitPos(int
The position of the digit to pop, counted in BCD units from the least significant digit. If outside the range supported by the implementation, an AssertionError is thrown.
position
,
byte
The digit to set at the specified location.
value
)

Sets the digit in the BCD list.

public void
setMinFraction(int
The minimum number of fraction digits.
minFrac
)

Implements com.ibm.icu.impl.number.DecimalQuantity.setMinFraction.

Sets the minimum fraction digits that this DecimalQuantity should generate.
public void
setMinInteger(int
The minimum number of integer digits.
minInt
)

Implements com.ibm.icu.impl.number.DecimalQuantity.setMinInteger.

Sets the minimum integer digits that this DecimalQuantity should generate.
public void
setToBigDecimal(BigDecimal
The value to consume.
n
)

Implements com.ibm.icu.impl.number.DecimalQuantity.setToBigDecimal.

Sets the internal BCD state to represent the value in the given BigDecimal.
public void
public void
setToDouble(double
The value to consume.
n
)

Sets the internal BCD state to represent the value in the given double.

public void
setToInt(int n)

public void
setToLong(long n)

protected abstract void
shiftLeft(int
The number of zeros to add.
numDigits
)

Adds zeros to the end of the BCD list.

protected abstract void
shiftRight(int
The number of digits to remove.
numDigits
)

Removes digits from the end of the BCD list.

public Modifier.Signum
public BigDecimal
public double

Returns:

A double representation of the internal BCD.
toDouble
()

Implements com.ibm.icu.impl.number.DecimalQuantity.toDouble.

Returns a double approximating the internal BCD.
public String
toExponentString()

Implements com.ibm.icu.impl.number.DecimalQuantity.toExponentString.

Returns the string using ASCII digits and using exponential notation for non-zero exponents, following the UTS 35 specification for plural rule samples.
private void
public long
toFractionLong(boolean includeTrailingZeros)

This returns a long representing the fraction digits of the number, as required by PluralRules.

public long
toLong(boolean
if false and the number does NOT fit, fails with an error. See comment about call site guards in DecimalQuantity_AbstractBCD.java
truncateIfOverflow
)

Implements com.ibm.icu.impl.number.DecimalQuantity.toLong.

Returns a long approximating the decimal quantity.
public String
toPlainString()

Implements com.ibm.icu.impl.number.DecimalQuantity.toPlainString.

Returns the string in "plain" format (no exponential notation) using ASCII digits.
public void
public String
public void
public void
truncate()

Removes all fraction digits.

Inherited from java.lang.Object:
clonefinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DOUBLE_MULTIPLIERSback to summary
private static final double[] DOUBLE_MULTIPLIERS
explicitExactDoubleback to summary
public boolean explicitExactDouble

Deprecated

This API is ICU internal only.

Whether this DecimalQuantity_DualStorageBCD has been explicitly converted to an exact double. true if backed by a double that was explicitly converted via convertToAccurateDouble; false otherwise. Used for testing.

Annotations
@Deprecated
ICU Status
Internal ICU component.
exponentback to summary
protected int exponent

The value of the (suppressed) exponent after the number has been put into a notation with exponents (ex: compact, scientific).

flagsback to summary
protected byte flags

A bitmask of properties relating to the number represented by this object.

See Also
NEGATIVE_FLAG, INFINITY_FLAG, NAN_FLAG
INFINITY_FLAGback to summary
protected static final int INFINITY_FLAG
INT64_BCDback to summary
pack-priv static final byte[] INT64_BCD
isApproximateback to summary
protected boolean isApproximate

Whether the value in the BCD comes from the double fast path without having been rounded to ensure correctness

lReqPosback to summary
protected int lReqPos
NAN_FLAGback to summary
protected static final int NAN_FLAG
NEGATIVE_FLAGback to summary
protected static final int NEGATIVE_FLAG
origDeltaback to summary
protected int origDelta

The change in magnitude relative to the original double. Used when we need to re-compute the BCD for an exact double representation.

origDoubleback to summary
protected double origDouble

The original number provided by the user and which is represented in BCD. Used when we need to re-compute the BCD for an exact double representation.

precisionback to summary
protected int precision

The number of digits in the BCD. For example, "1007" has BCD "0x1007" and precision 4. A long cannot represent precisions greater than 16.

This value must be re-calculated whenever the value in bcd changes by using computePrecisionAndCompact().

rReqPosback to summary
protected int rReqPos
scaleback to summary
protected int scale

The power of ten corresponding to the least significant digit in the BCD. For example, if this object represents the number "3.14", the BCD will be "0x314" and the scale will be -2.

Note that in java.math.BigDecimal, the scale is defined differently: the number of digits after the decimal place, which is the negative of our definition of scale.

SECTION_LOWER_EDGEback to summary
private static final int SECTION_LOWER_EDGE
SECTION_UPPER_EDGEback to summary
private static final int SECTION_UPPER_EDGE

Constructor Detail

DecimalQuantity_AbstractBCDback to summary
public DecimalQuantity_AbstractBCD()

Method Detail

_setToBigDecimalback to summary
private void _setToBigDecimal(BigDecimal n)
_setToBigIntegerback to summary
private void _setToBigInteger(BigInteger n)
_setToDoubleFastback to summary
private void _setToDoubleFast(double n)

Uses double multiplication and division to get the number into integer space before converting to digits. Since double arithmetic is inexact, the resulting digits may not be accurate.

_setToIntback to summary
private void _setToInt(int n)
_setToLongback to summary
private void _setToLong(long n)
adjustExponentback to summary
public void adjustExponent(int delta)

Implements com.ibm.icu.impl.number.DecimalQuantity.adjustExponent.

Doc from com.ibm.icu.impl.number.DecimalQuantity.adjustExponent.

Adjusts the value for the (suppressed) exponent stored when using notation with exponents (ex: compact, scientific).

Adjusting the exponent is decoupled from adjustMagnitude in order to allow flexibility for StandardPlural to be selected in formatting (ex: for compact notation) either with or without the exponent applied in the value of the number.

Parameters
delta:int

The value to adjust the exponent by.

Annotations
@Override
adjustMagnitudeback to summary
public void adjustMagnitude(int delta)

Implements com.ibm.icu.impl.number.DecimalQuantity.adjustMagnitude.

Doc from com.ibm.icu.impl.number.DecimalQuantity.adjustMagnitude.

Scales the number by a power of ten. For example, if the value is currently "1234.56", calling this method with delta=-3 will change the value to "1.23456".

Parameters
delta:int

The number of magnitudes of ten to change by.

Annotations
@Override
appendDigitback to summary
public void appendDigit(byte value, int leadingZeros, boolean appendAsInteger)

Deprecated

This API is ICU internal only.

Appends a digit, optionally with one or more leading zeros, to the end of the value represented by this DecimalQuantity.

The primary use of this method is to construct numbers during a parsing loop. It allows parsing to take advantage of the digit list infrastructure primarily designed for formatting.

Parameters
value:byte

The digit to append.

leadingZeros:int

The number of zeros to append before the digit. For example, if the value in this instance starts as 12.3, and you append a 4 with 1 leading zero, the value becomes 12.304.

appendAsInteger:boolean

If true, increase the magnitude of existing digits to make room for the new digit. If false, append to the end like a fraction digit. If true, there must not be any fraction digits already in the number.

Annotations
@Deprecated
ICU Status
Internal ICU component.
applyMaxIntegerback to summary
public void applyMaxInteger(int maxInt)

Implements com.ibm.icu.impl.number.DecimalQuantity.applyMaxInteger.

Doc from com.ibm.icu.impl.number.DecimalQuantity.applyMaxInteger.

Truncates digits from the upper magnitude of the number in order to satisfy the specified maximum number of integer digits.

Parameters
maxInt:int

The maximum number of integer digits.

Annotations
@Override
bcdToBigDecimalback to summary
protected abstract BigDecimal bcdToBigDecimal()

Returns a BigDecimal encoding the internal BCD value.

Returns:BigDecimal

A BigDecimal representation of the internal BCD.

clearback to summary
public DecimalQuantity_AbstractBCD clear()

Deprecated

as a consequence of DecimalQuantity_AbstractBCD being deprecated. See corresponding docs for further information.

compactback to summary
protected abstract void compact()

Removes trailing zeros from the BCD (adjusting the scale as required) and then computes the precision. The precision is the number of digits in the number up through the greatest nonzero digit.

This method must always be called when bcd changes in order for assumptions to be correct in methods like fractionCount().

convertToAccurateDoubleback to summary
private void convertToAccurateDouble()

Uses Double.toString() to obtain an exact accurate representation of the double, overwriting it into the BCD. This method can be called at any point after _setToDoubleFast while isApproximate is still true.

copyBcdFromback to summary
protected abstract void copyBcdFrom(DecimalQuantity _other)

Deprecated

as a consequence of DecimalQuantity being deprecated. See corresponding docs for further information.

copyFromback to summary
public void copyFrom(DecimalQuantity _other)

Implements com.ibm.icu.impl.number.DecimalQuantity.copyFrom.

Doc from com.ibm.icu.impl.number.DecimalQuantity.copyFrom.

Deprecated

as a consequence of DecimalQuantity being deprecated. See corresponding docs for further information.

Sets this instance to be equal to another instance.

Parameters
_other:DecimalQuantity

The instance to copy from.

Annotations
@Override
equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
other:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
fitsInLongback to summary
public boolean fitsInLong()

Returns whether or not a Long can fully represent the value stored in this DecimalQuantity.

fractionCountback to summary
private int fractionCount()
fractionCountWithoutTrailingZerosback to summary
private int fractionCountWithoutTrailingZeros()
getDigitback to summary
public byte getDigit(int magnitude)

Implements com.ibm.icu.impl.number.DecimalQuantity.getDigit.

Doc from com.ibm.icu.impl.number.DecimalQuantity.getDigit.

Gets the digit at the specified magnitude. For example, if the represented number is 12.3, getDigit(-1) returns 3, since 3 is the digit corresponding to 10^-1.

Parameters
magnitude:int

The magnitude of the digit.

Returns:byte

The digit at the specified magnitude.

Annotations
@Override
getDigitPosback to summary
protected abstract byte getDigitPos(int position)

Returns a single digit from the BCD list. No internal state is changed by calling this method.

Parameters
position:int

The position of the digit to pop, counted in BCD units from the least significant digit. If outside the range supported by the implementation, zero is returned.

Returns:byte

The digit at the specified location.

getExponentback to summary
public int getExponent()

Implements com.ibm.icu.impl.number.DecimalQuantity.getExponent.

Returns:int

Doc from com.ibm.icu.impl.number.DecimalQuantity.getExponent.

The value of the (suppressed) exponent after the number has been put into a notation with exponents (ex: compact, scientific). Ex: given the number 1000 as "1K" / "1E3", the return value will be 3 (positive).

Annotations
@Override
getLowerDisplayMagnitudeback to summary
public int getLowerDisplayMagnitude()

Implements com.ibm.icu.impl.number.DecimalQuantity.getLowerDisplayMagnitude.

Doc from com.ibm.icu.impl.number.DecimalQuantity.getLowerDisplayMagnitude.

Gets the smallest power of ten that needs to be displayed. The value returned by this function will be bounded between -minFrac and -maxFrac.

Returns:int

The lowest-magnitude digit to be displayed.

Annotations
@Override
getMagnitudeback to summary
public int getMagnitude() throws ArithmeticException

Implements com.ibm.icu.impl.number.DecimalQuantity.getMagnitude.

Returns:int

Doc from com.ibm.icu.impl.number.DecimalQuantity.getMagnitude.

The power of ten corresponding to the most significant nonzero digit.

Annotations
@Override
Exceptions
ArithmeticException:

Doc from com.ibm.icu.impl.number.DecimalQuantity.getMagnitude.

If the value represented is zero.

getPluralOperandback to summary
public double getPluralOperand(PluralRules.Operand operand)

Implements com.ibm.icu.text.PluralRules.IFixedDecimal.getPluralOperand.

Doc from com.ibm.icu.text.PluralRules.IFixedDecimal.getPluralOperand.

Deprecated

as a consequence of PluralRules.Operand being deprecated. See corresponding docs for further information.

Returns the value corresponding to the specified operand (n, i, f, t, v, or w). If the operand is 'n', returns a double; otherwise, returns an integer.

Annotations
@Override
getPositionFingerprintback to summary
public long getPositionFingerprint()

Implements com.ibm.icu.impl.number.DecimalQuantity.getPositionFingerprint.

Doc from com.ibm.icu.impl.number.DecimalQuantity.getPositionFingerprint.

This method is for internal testing only.

Annotations
@Override
getStandardPluralback to summary
public StandardPlural getStandardPlural(PluralRules rules)

Implements com.ibm.icu.impl.number.DecimalQuantity.getStandardPlural.

Doc from com.ibm.icu.impl.number.DecimalQuantity.getStandardPlural.

Computes the plural form for this number based on the specified set of rules.

Parameters
rules:PluralRules

A PluralRules object representing the set of rules.

Returns:StandardPlural

The StandardPlural according to the PluralRules. If the plural form is not in the set of standard plurals, StandardPlural#OTHER is returned instead.

Annotations
@Override
getUpperDisplayMagnitudeback to summary
public int getUpperDisplayMagnitude()

Implements com.ibm.icu.impl.number.DecimalQuantity.getUpperDisplayMagnitude.

Doc from com.ibm.icu.impl.number.DecimalQuantity.getUpperDisplayMagnitude.

Gets the largest power of ten that needs to be displayed. The value returned by this function will be bounded between minInt and maxInt.

Returns:int

The highest-magnitude digit to be displayed.

Annotations
@Override
isHasIntegerValueback to summary
public boolean isHasIntegerValue()

Implements com.ibm.icu.text.PluralRules.IFixedDecimal.isHasIntegerValue.

Doc from com.ibm.icu.text.PluralRules.IFixedDecimal.isHasIntegerValue.

Whether the number has no nonzero fraction digits.

Annotations
@Override
isInfiniteback to summary
public boolean isInfinite()

Implements com.ibm.icu.impl.number.DecimalQuantity.isInfinite.

Returns:boolean

Doc from com.ibm.icu.impl.number.DecimalQuantity.isInfinite.

Whether the value represented by this DecimalQuantity is infinite.

Annotations
@Override
isNaNback to summary
public boolean isNaN()

Implements com.ibm.icu.impl.number.DecimalQuantity.isNaN.

Returns:boolean

Doc from com.ibm.icu.impl.number.DecimalQuantity.isNaN.

Whether the value represented by this DecimalQuantity is not a number.

Annotations
@Override
isNegativeback to summary
public boolean isNegative()

Implements com.ibm.icu.impl.number.DecimalQuantity.isNegative.

Returns:boolean

Doc from com.ibm.icu.impl.number.DecimalQuantity.isNegative.

Whether the value represented by this DecimalQuantity is less than zero.

Annotations
@Override
isZeroishback to summary
public boolean isZeroish()

Implements com.ibm.icu.impl.number.DecimalQuantity.isZeroish.

Returns:boolean

Doc from com.ibm.icu.impl.number.DecimalQuantity.isZeroish.

Whether the value represented by this DecimalQuantity is zero, infinity, or NaN.

Annotations
@Override
multiplyByback to summary
public void multiplyBy(BigDecimal multiplicand)

Implements com.ibm.icu.impl.number.DecimalQuantity.multiplyBy.

Doc from com.ibm.icu.impl.number.DecimalQuantity.multiplyBy.

Multiply the internal value.

Parameters
multiplicand:BigDecimal

The value by which to multiply.

Annotations
@Override
negateback to summary
public void negate()

Implements com.ibm.icu.impl.number.DecimalQuantity.negate.

Doc from com.ibm.icu.impl.number.DecimalQuantity.negate.

Flips the sign from positive to negative and back.

Annotations
@Override
popFromLeftback to summary
protected abstract void popFromLeft(int numDigits)

Directly removes digits from the front of the BCD list. Updates precision.

Caution

it is the caller's responsibility to call compact after this method.

populateUFieldPositionback to summary
public void populateUFieldPosition(FieldPosition fp)

Implements com.ibm.icu.impl.number.DecimalQuantity.populateUFieldPosition.

Doc from com.ibm.icu.impl.number.DecimalQuantity.populateUFieldPosition.

If the given FieldPosition is a UFieldPosition, populates it with the fraction length and fraction long value. If the argument is not a UFieldPosition, nothing happens.

Parameters
fp:FieldPosition

The UFieldPosition to populate.

Annotations
@Override
readBigIntegerToBcdback to summary
protected abstract void readBigIntegerToBcd(BigInteger input)

Sets the internal BCD state to represent the value in the given BigInteger. The BigInteger is guaranteed to be positive, and it is guaranteed to be larger than Long.MAX_VALUE. The internal state is guaranteed to be empty when this method is called.

Parameters
input:BigInteger

The value to consume.

readIntToBcdback to summary
protected abstract void readIntToBcd(int input)

Sets the internal BCD state to represent the value in the given int. The int is guaranteed to be either positive. The internal state is guaranteed to be empty when this method is called.

Parameters
input:int

The value to consume.

readLongToBcdback to summary
protected abstract void readLongToBcd(long input)

Sets the internal BCD state to represent the value in the given long. The long is guaranteed to be either positive. The internal state is guaranteed to be empty when this method is called.

Parameters
input:long

The value to consume.

resetExponentback to summary
public void resetExponent()

Implements com.ibm.icu.impl.number.DecimalQuantity.resetExponent.

Doc from com.ibm.icu.impl.number.DecimalQuantity.resetExponent.

Resets the DecimalQuantity to the value before adjustMagnitude and adjustExponent.

Annotations
@Override
roundToIncrementback to summary
public void roundToIncrement(BigDecimal roundingIncrement, MathContext mathContext)

Implements com.ibm.icu.impl.number.DecimalQuantity.roundToIncrement.

Doc from com.ibm.icu.impl.number.DecimalQuantity.roundToIncrement.

Rounds the number to a specified interval, such as 0.05.

If rounding to a power of ten, use the more efficient roundToMagnitude instead.

Parameters
roundingIncrement:BigDecimal

The increment to which to round.

mathContext:MathContext

The MathContext to use if rounding is necessary. Undefined behavior if null.

Annotations
@Override
roundToInfinityback to summary
public void roundToInfinity()

Implements com.ibm.icu.impl.number.DecimalQuantity.roundToInfinity.

Doc from com.ibm.icu.impl.number.DecimalQuantity.roundToInfinity.

Rounds the number to an infinite number of decimal points. This has no effect except for forcing the double in DecimalQuantity_AbstractBCD to adopt its exact representation.

Annotations
@Override
roundToMagnitudeback to summary
public void roundToMagnitude(int magnitude, MathContext mathContext)

Implements com.ibm.icu.impl.number.DecimalQuantity.roundToMagnitude.

Doc from com.ibm.icu.impl.number.DecimalQuantity.roundToMagnitude.

Rounds the number to a specified magnitude (power of ten).

Parameters
magnitude:int

The power of ten to which to round. For example, a value of -2 will round to 2 decimal places.

mathContext:MathContext

The MathContext to use if rounding is necessary. Undefined behavior if null.

Annotations
@Override
roundToMagnitudeback to summary
private void roundToMagnitude(int magnitude, MathContext mathContext, boolean nickel)
roundToNickelback to summary
public void roundToNickel(int magnitude, MathContext mathContext)

Implements com.ibm.icu.impl.number.DecimalQuantity.roundToNickel.

Doc from com.ibm.icu.impl.number.DecimalQuantity.roundToNickel.

Rounds the number to the nearest multiple of 5 at the specified magnitude. For example, when magnitude == -2, this performs rounding to the nearest 0.05.

Parameters
magnitude:int

The magnitude at which the digit should become either 0 or 5.

mathContext:MathContext

Rounding strategy.

Annotations
@Override
safeSubtractback to summary
private static int safeSubtract(int a, int b)
setBcdToZeroback to summary
protected abstract void setBcdToZero()

Sets the internal representation to zero. Clears any values stored in scale, precision, hasDouble, origDouble, origDelta, exponent, and BCD data.

setDigitPosback to summary
protected abstract void setDigitPos(int position, byte value)

Sets the digit in the BCD list. This method only sets the digit; it is the caller's responsibility to call compact after setting the digit, and to ensure that the precision field is updated to reflect the correct number of digits if a nonzero digit is added to the decimal.

Parameters
position:int

The position of the digit to pop, counted in BCD units from the least significant digit. If outside the range supported by the implementation, an AssertionError is thrown.

value:byte

The digit to set at the specified location.

setMinFractionback to summary
public void setMinFraction(int minFrac)

Implements com.ibm.icu.impl.number.DecimalQuantity.setMinFraction.

Doc from com.ibm.icu.impl.number.DecimalQuantity.setMinFraction.

Sets the minimum fraction digits that this DecimalQuantity should generate. This method does not perform rounding.

Parameters
minFrac:int

The minimum number of fraction digits.

Annotations
@Override
setMinIntegerback to summary
public void setMinInteger(int minInt)

Implements com.ibm.icu.impl.number.DecimalQuantity.setMinInteger.

Doc from com.ibm.icu.impl.number.DecimalQuantity.setMinInteger.

Sets the minimum integer digits that this DecimalQuantity should generate. This method does not perform rounding.

Parameters
minInt:int

The minimum number of integer digits.

Annotations
@Override
setToBigDecimalback to summary
public void setToBigDecimal(BigDecimal n)

Implements com.ibm.icu.impl.number.DecimalQuantity.setToBigDecimal.

Sets the internal BCD state to represent the value in the given BigDecimal.

Parameters
n:BigDecimal

The value to consume.

Annotations
@Override
setToBigIntegerback to summary
public void setToBigInteger(BigInteger n)
setToDoubleback to summary
public void setToDouble(double n)

Sets the internal BCD state to represent the value in the given double.

Parameters
n:double

The value to consume.

setToIntback to summary
public void setToInt(int n)
setToLongback to summary
public void setToLong(long n)
shiftLeftback to summary
protected abstract void shiftLeft(int numDigits)

Adds zeros to the end of the BCD list. This will result in an invalid BCD representation; it is the caller's responsibility to do further manipulation and then call compact.

Parameters
numDigits:int

The number of zeros to add.

shiftRightback to summary
protected abstract void shiftRight(int numDigits)

Removes digits from the end of the BCD list. This may result in an invalid BCD representation; it is the caller's responsibility to follow-up with a call to compact.

Parameters
numDigits:int

The number of digits to remove.

signumback to summary
public Modifier.Signum signum()

Implements com.ibm.icu.impl.number.DecimalQuantity.signum.

Returns:Modifier.Signum

Doc from com.ibm.icu.impl.number.DecimalQuantity.signum.

The appropriate value from the Signum enum.

Annotations
@Override
toBigDecimalback to summary
public BigDecimal toBigDecimal()

Implements com.ibm.icu.impl.number.DecimalQuantity.toBigDecimal.

Annotations
@Override
toDoubleback to summary
public double toDouble()

Implements com.ibm.icu.impl.number.DecimalQuantity.toDouble.

Returns a double approximating the internal BCD. The double may not retain all of the information encoded in the BCD if the BCD represents a number out of range of a double.

Returns:double

A double representation of the internal BCD.

Annotations
@Override
toExponentStringback to summary
public String toExponentString()

Implements com.ibm.icu.impl.number.DecimalQuantity.toExponentString.

Doc from com.ibm.icu.impl.number.DecimalQuantity.toExponentString.

Returns the string using ASCII digits and using exponential notation for non-zero exponents, following the UTS 35 specification for plural rule samples.

Annotations
@Override
toExponentStringback to summary
private void toExponentString(StringBuilder result)
toFractionLongback to summary
public long toFractionLong(boolean includeTrailingZeros)

This returns a long representing the fraction digits of the number, as required by PluralRules. For example, if we represent the number "1.20" (including optional and required digits), then this function returns "20" if includeTrailingZeros is true or "2" if false.

Note

this method incorporates the value of exponent (for cases such as compact notation) to return the proper long value represented by the result.

toLongback to summary
public long toLong(boolean truncateIfOverflow)

Implements com.ibm.icu.impl.number.DecimalQuantity.toLong.

Doc from com.ibm.icu.impl.number.DecimalQuantity.toLong.

Returns a long approximating the decimal quantity. A long can only represent the integral part of the number.

Note

this method incorporates the value of getExponent (for cases such as compact notation) to return the proper long value represented by the result.

Parameters
truncateIfOverflow:boolean

if false and the number does NOT fit, fails with an error. See comment about call site guards in DecimalQuantity_AbstractBCD.java

Returns:long

A 64-bit integer representation of the internal number.

Annotations
@Override
toPlainStringback to summary
public String toPlainString()

Implements com.ibm.icu.impl.number.DecimalQuantity.toPlainString.

Doc from com.ibm.icu.impl.number.DecimalQuantity.toPlainString.

Returns the string in "plain" format (no exponential notation) using ASCII digits.

Annotations
@Override
toPlainStringback to summary
public void toPlainString(StringBuilder result)
toScientificStringback to summary
public String toScientificString()
toScientificStringback to summary
public void toScientificString(StringBuilder result)
truncateback to summary
public void truncate()

Removes all fraction digits.