Class DecimalQuantity_DualStorageBCD
java.lang.Object
org.graalvm.shadowed.com.ibm.icu.impl.number.DecimalQuantity_AbstractBCD
org.graalvm.shadowed.com.ibm.icu.impl.number.DecimalQuantity_DualStorageBCD
- All Implemented Interfaces:
DecimalQuantity, PluralRules.IFixedDecimal
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
Fields inherited from class DecimalQuantity_AbstractBCD
explicitExactDouble, exponent, flags, INFINITY_FLAG, isApproximate, lReqPos, NAN_FLAG, NEGATIVE_FLAG, origDelta, origDouble, precision, rReqPos, scale -
Constructor Summary
ConstructorsConstructorDescriptionDecimalQuantity_DualStorageBCD(double input) DecimalQuantity_DualStorageBCD(int input) DecimalQuantity_DualStorageBCD(long input) DecimalQuantity_DualStorageBCD(Number number) -
Method Summary
Modifier and TypeMethodDescriptionprotected BigDecimalReturns a BigDecimal encoding the internal BCD value.Deprecated.This API is for ICU internal use only.protected voidcompact()Removes trailing zeros from the BCD (adjusting the scale as required) and then computes the precision.protected voidcopyBcdFrom(DecimalQuantity _other) Like clone, but without the restrictions of the Cloneable interface clone.static DecimalQuantityfromExponentString(String num) Returns a DecimalQuantity after parsing the input string.protected bytegetDigitPos(int position) Returns a single digit from the BCD list.booleanDeprecated.This API is ICU internal only.intprotected voidpopFromLeft(int numDigits) Directly removes digits from the front of the BCD list.protected voidSets the internal BCD state to represent the value in the given BigInteger.protected voidreadIntToBcd(int n) Sets the internal BCD state to represent the value in the given int.protected voidreadLongToBcd(long n) Sets the internal BCD state to represent the value in the given long.protected voidSets the internal representation to zero.protected voidsetDigitPos(int position, byte value) Sets the digit in the BCD list.protected voidshiftLeft(int numDigits) Adds zeros to the end of the BCD list.protected voidshiftRight(int numDigits) Removes digits from the end of the BCD list.toString()Methods inherited from class DecimalQuantity_AbstractBCD
adjustExponent, adjustMagnitude, appendDigit, applyMaxInteger, clear, copyFrom, equals, fitsInLong, getDigit, getExponent, getLowerDisplayMagnitude, getMagnitude, getPluralOperand, getPositionFingerprint, getStandardPlural, getUpperDisplayMagnitude, isHasIntegerValue, isInfinite, isNaN, isNegative, isZeroish, multiplyBy, negate, populateUFieldPosition, resetExponent, roundToIncrement, roundToInfinity, roundToMagnitude, roundToNickel, setMinFraction, setMinInteger, setToBigDecimal, setToBigInteger, setToDouble, setToInt, setToLong, signum, toBigDecimal, toDouble, toExponentString, toFractionLong, toLong, toPlainString, toPlainString, toScientificString, toScientificString, truncate
-
Constructor Details
-
DecimalQuantity_DualStorageBCD
public DecimalQuantity_DualStorageBCD() -
DecimalQuantity_DualStorageBCD
public DecimalQuantity_DualStorageBCD(long input) -
DecimalQuantity_DualStorageBCD
public DecimalQuantity_DualStorageBCD(int input) -
DecimalQuantity_DualStorageBCD
public DecimalQuantity_DualStorageBCD(double input) -
DecimalQuantity_DualStorageBCD
-
DecimalQuantity_DualStorageBCD
-
DecimalQuantity_DualStorageBCD
-
DecimalQuantity_DualStorageBCD
-
-
Method Details
-
maxRepresentableDigits
public int maxRepresentableDigits() -
createCopy
Description copied from interface:DecimalQuantityLike clone, but without the restrictions of the Cloneable interface clone.- Returns:
- A copy of this instance which can be mutated without affecting this instance.
-
fromExponentString
Returns a DecimalQuantity after parsing the input string.- Parameters:
s- The String to parse
-
getDigitPos
protected byte getDigitPos(int position) Description copied from class:DecimalQuantity_AbstractBCDReturns a single digit from the BCD list. No internal state is changed by calling this method.- Specified by:
getDigitPosin classDecimalQuantity_AbstractBCD- Parameters:
position- 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:
- The digit at the specified location.
-
setDigitPos
protected void setDigitPos(int position, byte value) Description copied from class:DecimalQuantity_AbstractBCDSets the digit in the BCD list. This method only sets the digit; it is the caller's responsibility to callDecimalQuantity_AbstractBCD.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.- Specified by:
setDigitPosin classDecimalQuantity_AbstractBCD- Parameters:
position- 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- The digit to set at the specified location.
-
shiftLeft
protected void shiftLeft(int numDigits) Description copied from class:DecimalQuantity_AbstractBCDAdds 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 callDecimalQuantity_AbstractBCD.compact().- Specified by:
shiftLeftin classDecimalQuantity_AbstractBCD- Parameters:
numDigits- The number of zeros to add.
-
shiftRight
protected void shiftRight(int numDigits) Description copied from class:DecimalQuantity_AbstractBCDRemoves 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 toDecimalQuantity_AbstractBCD.compact().- Specified by:
shiftRightin classDecimalQuantity_AbstractBCD- Parameters:
numDigits- The number of digits to remove.
-
popFromLeft
protected void popFromLeft(int numDigits) Description copied from class:DecimalQuantity_AbstractBCDDirectly removes digits from the front of the BCD list. Updates precision. CAUTION: it is the caller's responsibility to callDecimalQuantity_AbstractBCD.compact()after this method.- Specified by:
popFromLeftin classDecimalQuantity_AbstractBCD
-
setBcdToZero
protected void setBcdToZero()Description copied from class:DecimalQuantity_AbstractBCDSets the internal representation to zero. Clears any values stored in scale, precision, hasDouble, origDouble, origDelta, exponent, and BCD data.- Specified by:
setBcdToZeroin classDecimalQuantity_AbstractBCD
-
readIntToBcd
protected void readIntToBcd(int n) Description copied from class:DecimalQuantity_AbstractBCDSets 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.- Specified by:
readIntToBcdin classDecimalQuantity_AbstractBCD
-
readLongToBcd
protected void readLongToBcd(long n) Description copied from class:DecimalQuantity_AbstractBCDSets 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.- Specified by:
readLongToBcdin classDecimalQuantity_AbstractBCD
-
readBigIntegerToBcd
Description copied from class:DecimalQuantity_AbstractBCDSets 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.- Specified by:
readBigIntegerToBcdin classDecimalQuantity_AbstractBCD
-
bcdToBigDecimal
Description copied from class:DecimalQuantity_AbstractBCDReturns a BigDecimal encoding the internal BCD value.- Specified by:
bcdToBigDecimalin classDecimalQuantity_AbstractBCD- Returns:
- A BigDecimal representation of the internal BCD.
-
compact
protected void compact()Description copied from class:DecimalQuantity_AbstractBCDRemoves 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
DecimalQuantity_AbstractBCD.fractionCount().- Specified by:
compactin classDecimalQuantity_AbstractBCD
-
copyBcdFrom
- Specified by:
copyBcdFromin classDecimalQuantity_AbstractBCD
-
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:
- An error message if this instance is invalid, or null if this instance is healthy.
-
isUsingBytes
Deprecated.This API is ICU internal only.Checks whether thisDecimalQuantity_DualStorageBCDis using its internal byte array storage mechanism.- Returns:
- true if an internal byte array is being used; false if a long is being used.
-
toString
-