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

public final Class DecimalQuantity_DualStorageBCD

extends DecimalQuantity_AbstractBCD
Class Inheritance
Imports
java.math.BigDecimal, .BigInteger, java.util.Arrays

Deprecated

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

A DecimalQuantity with internal storage as a 64-bit BCD, with fallback to a byte array for numbers that don't fit into the standard BCD.

Field Summary

Modifier and TypeField and Description
private byte[]
bcdBytes

The BCD of the 16 digits of the number represented by this object.

private long
private boolean
Inherited from com.ibm.icu.impl.number.DecimalQuantity_AbstractBCD:
explicitExactDoubleexponentflagsINFINITY_FLAGINT64_BCDisApproximatelReqPosNAN_FLAGNEGATIVE_FLAGorigDeltaorigDoubleprecisionrReqPosscale

Constructor Summary

AccessConstructor and Description
public
public
public
public
public
public
public
public

Method Summary

Modifier and TypeMethod and Description
protected BigDecimal
bcdToBigDecimal()

Implements abstract com.ibm.icu.impl.number.DecimalQuantity_AbstractBCD.bcdToBigDecimal.

Returns a BigDecimal encoding the internal BCD value.
public String

Returns:

An error message if this instance is invalid, or null if this instance is healthy.
checkHealth
()

Deprecated This API is for ICU internal use only.
Checks whether the bytes stored in this instance are all valid.
protected void
compact()

Implements abstract com.ibm.icu.impl.number.DecimalQuantity_AbstractBCD.compact.

Removes trailing zeros from the BCD (adjusting the scale as required) and then computes the precision.
protected void
copyBcdFrom(DecimalQuantity _other)

Implements abstract com.ibm.icu.impl.number.DecimalQuantity_AbstractBCD.copyBcdFrom.

Deprecated as a consequence of DecimalQuantity being deprecated.
public DecimalQuantity
createCopy()

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

Deprecated as a consequence of DecimalQuantity being deprecated.
Like clone, but without the restrictions of the Cloneable interface clone.
private void
ensureCapacity()

Ensure that a byte array of at least 40 digits is allocated.

private void
ensureCapacity(int capacity)

public static DecimalQuantity
fromExponentString(String
The String to parse
num
)

Deprecated as a consequence of DecimalQuantity being deprecated.
Returns a DecimalQuantity after parsing the input string.
protected byte
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
)

Implements abstract com.ibm.icu.impl.number.DecimalQuantity_AbstractBCD.getDigitPos.

Returns a single digit from the BCD list.
private static int
public boolean

Returns:

true if an internal byte array is being used; false if a long is being used.
isUsingBytes
()

Deprecated This API is ICU internal only.
Checks whether this DecimalQuantity_DualStorageBCD is using its internal byte array storage mechanism.
public int
protected void
popFromLeft(int numDigits)

Implements abstract com.ibm.icu.impl.number.DecimalQuantity_AbstractBCD.popFromLeft.

Directly removes digits from the front of the BCD list.
protected void
readBigIntegerToBcd(BigInteger
The value to consume.
n
)

Implements abstract com.ibm.icu.impl.number.DecimalQuantity_AbstractBCD.readBigIntegerToBcd.

Sets the internal BCD state to represent the value in the given BigInteger.
protected void
readIntToBcd(int
The value to consume.
n
)

Implements abstract com.ibm.icu.impl.number.DecimalQuantity_AbstractBCD.readIntToBcd.

Sets the internal BCD state to represent the value in the given int.
protected void
readLongToBcd(long
The value to consume.
n
)

Implements abstract com.ibm.icu.impl.number.DecimalQuantity_AbstractBCD.readLongToBcd.

Sets the internal BCD state to represent the value in the given long.
protected void
setBcdToZero()

Implements abstract com.ibm.icu.impl.number.DecimalQuantity_AbstractBCD.setBcdToZero.

Sets the internal representation to zero.
protected 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
)

Implements abstract com.ibm.icu.impl.number.DecimalQuantity_AbstractBCD.setDigitPos.

Sets the digit in the BCD list.
protected void
shiftLeft(int
The number of zeros to add.
numDigits
)

Implements abstract com.ibm.icu.impl.number.DecimalQuantity_AbstractBCD.shiftLeft.

Adds zeros to the end of the BCD list.
protected void
shiftRight(int
The number of digits to remove.
numDigits
)

Implements abstract com.ibm.icu.impl.number.DecimalQuantity_AbstractBCD.shiftRight.

Removes digits from the end of the BCD list.
private void
switchStorage()

Switches the internal storage mechanism between the 64-bit long and the byte array.

private String
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from com.ibm.icu.impl.number.DecimalQuantity_AbstractBCD:
adjustExponentadjustMagnitudeappendDigitapplyMaxIntegerclearcopyFromequalsfitsInLonggetDigitgetExponentgetLowerDisplayMagnitudegetMagnitudegetPluralOperandgetPositionFingerprintgetStandardPluralgetUpperDisplayMagnitudeisHasIntegerValueisInfiniteisNaNisNegativeisZeroishmultiplyBynegatepopulateUFieldPositionresetExponentroundToIncrementroundToInfinityroundToMagnituderoundToNickelsetMinFractionsetMinIntegersetToBigDecimalsetToBigIntegersetToDoublesetToIntsetToLongsignumtoBigDecimaltoDoubletoExponentStringtoFractionLongtoLongtoPlainStringtoPlainStringtoScientificStringtoScientificStringtruncate

Field Detail

bcdBytesback to summary
private byte[] bcdBytes

The BCD of the 16 digits of the number represented by this object. Every 4 bits of the long map to one digit. For example, the number "12345" in BCD is "0x12345".

Whenever bcd changes internally, compact() must be called, except in special cases like setting the digit to zero.

bcdLongback to summary
private long bcdLong
usingBytesback to summary
private boolean usingBytes

Constructor Detail

DecimalQuantity_DualStorageBCDback to summary
public DecimalQuantity_DualStorageBCD()
DecimalQuantity_DualStorageBCDback to summary
public DecimalQuantity_DualStorageBCD(long input)
DecimalQuantity_DualStorageBCDback to summary
public DecimalQuantity_DualStorageBCD(int input)
DecimalQuantity_DualStorageBCDback to summary
public DecimalQuantity_DualStorageBCD(double input)
DecimalQuantity_DualStorageBCDback to summary
public DecimalQuantity_DualStorageBCD(BigInteger input)
DecimalQuantity_DualStorageBCDback to summary
public DecimalQuantity_DualStorageBCD(BigDecimal input)
DecimalQuantity_DualStorageBCDback to summary
public DecimalQuantity_DualStorageBCD(DecimalQuantity_DualStorageBCD other)

Deprecated

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

DecimalQuantity_DualStorageBCDback to summary
public DecimalQuantity_DualStorageBCD(Number number)

Method Detail

bcdToBigDecimalback to summary
protected BigDecimal bcdToBigDecimal()

Implements abstract com.ibm.icu.impl.number.DecimalQuantity_AbstractBCD.bcdToBigDecimal.

Doc from com.ibm.icu.impl.number.DecimalQuantity_AbstractBCD.bcdToBigDecimal.

Returns a BigDecimal encoding the internal BCD value.

Returns:BigDecimal

A BigDecimal representation of the internal BCD.

Annotations
@Override
checkHealthback to summary
public String checkHealth()

Deprecated

This API is for ICU internal use only.

Checks whether the bytes stored in this instance are all valid. For internal unit testing only.

Returns:String

An error message if this instance is invalid, or null if this instance is healthy.

Annotations
@Deprecated
ICU Status
Internal ICU component.
compactback to summary
protected void compact()

Implements abstract com.ibm.icu.impl.number.DecimalQuantity_AbstractBCD.compact.

Doc from com.ibm.icu.impl.number.DecimalQuantity_AbstractBCD.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().

Annotations
@Override
copyBcdFromback to summary
protected void copyBcdFrom(DecimalQuantity _other)

Implements abstract com.ibm.icu.impl.number.DecimalQuantity_AbstractBCD.copyBcdFrom.

Deprecated

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

Annotations
@Override
createCopyback to summary
public DecimalQuantity createCopy()

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

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

Deprecated

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

Like clone, but without the restrictions of the Cloneable interface clone.

Returns:DecimalQuantity

A copy of this instance which can be mutated without affecting this instance.

Annotations
@Override
ensureCapacityback to summary
private void ensureCapacity()

Ensure that a byte array of at least 40 digits is allocated.

ensureCapacityback to summary
private void ensureCapacity(int capacity)
fromExponentStringback to summary
public static DecimalQuantity fromExponentString(String num)

Deprecated

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

Returns a DecimalQuantity after parsing the input string.

Parameters
num:String

The String to parse

getDigitPosback to summary
protected byte getDigitPos(int position)

Implements abstract com.ibm.icu.impl.number.DecimalQuantity_AbstractBCD.getDigitPos.

Doc from com.ibm.icu.impl.number.DecimalQuantity_AbstractBCD.getDigitPos.

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.

Annotations
@Override
getVisibleFractionCountback to summary
private static int getVisibleFractionCount(String value)
isUsingBytesback to summary
public boolean isUsingBytes()

Deprecated

This API is ICU internal only.

Checks whether this DecimalQuantity_DualStorageBCD is using its internal byte array storage mechanism.

Returns:boolean

true if an internal byte array is being used; false if a long is being used.

Annotations
@Deprecated
ICU Status
Internal ICU component.
maxRepresentableDigitsback to summary
public int maxRepresentableDigits()

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

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

Implements abstract com.ibm.icu.impl.number.DecimalQuantity_AbstractBCD.popFromLeft.

Doc from com.ibm.icu.impl.number.DecimalQuantity_AbstractBCD.popFromLeft.

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.

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

Implements abstract com.ibm.icu.impl.number.DecimalQuantity_AbstractBCD.readBigIntegerToBcd.

Doc from com.ibm.icu.impl.number.DecimalQuantity_AbstractBCD.readBigIntegerToBcd.

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
n:BigInteger

The value to consume.

Annotations
@Override
readIntToBcdback to summary
protected void readIntToBcd(int n)

Implements abstract com.ibm.icu.impl.number.DecimalQuantity_AbstractBCD.readIntToBcd.

Doc from com.ibm.icu.impl.number.DecimalQuantity_AbstractBCD.readIntToBcd.

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
n:int

The value to consume.

Annotations
@Override
readLongToBcdback to summary
protected void readLongToBcd(long n)

Implements abstract com.ibm.icu.impl.number.DecimalQuantity_AbstractBCD.readLongToBcd.

Doc from com.ibm.icu.impl.number.DecimalQuantity_AbstractBCD.readLongToBcd.

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
n:long

The value to consume.

Annotations
@Override
setBcdToZeroback to summary
protected void setBcdToZero()

Implements abstract com.ibm.icu.impl.number.DecimalQuantity_AbstractBCD.setBcdToZero.

Doc from com.ibm.icu.impl.number.DecimalQuantity_AbstractBCD.setBcdToZero.

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

Annotations
@Override
setDigitPosback to summary
protected void setDigitPos(int position, byte value)

Implements abstract com.ibm.icu.impl.number.DecimalQuantity_AbstractBCD.setDigitPos.

Doc from com.ibm.icu.impl.number.DecimalQuantity_AbstractBCD.setDigitPos.

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.

Annotations
@Override
shiftLeftback to summary
protected void shiftLeft(int numDigits)

Implements abstract com.ibm.icu.impl.number.DecimalQuantity_AbstractBCD.shiftLeft.

Doc from com.ibm.icu.impl.number.DecimalQuantity_AbstractBCD.shiftLeft.

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.

Annotations
@Override
shiftRightback to summary
protected void shiftRight(int numDigits)

Implements abstract com.ibm.icu.impl.number.DecimalQuantity_AbstractBCD.shiftRight.

Doc from com.ibm.icu.impl.number.DecimalQuantity_AbstractBCD.shiftRight.

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.

Annotations
@Override
switchStorageback to summary
private void switchStorage()

Switches the internal storage mechanism between the 64-bit long and the byte array.

toNumberStringback to summary
private String toNumberString()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override