Class DecimalQuantity_DualStorageBCD

    • Field Detail

      • bcdBytes

        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.

      • bcdLong

        private long bcdLong
      • usingBytes

        private boolean usingBytes
    • Constructor Detail

      • 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

        public DecimalQuantity_DualStorageBCD​(java.math.BigInteger input)
      • DecimalQuantity_DualStorageBCD

        public DecimalQuantity_DualStorageBCD​(java.math.BigDecimal input)
      • DecimalQuantity_DualStorageBCD

        public DecimalQuantity_DualStorageBCD​(java.lang.Number number)
    • Method Detail

      • maxRepresentableDigits

        public int maxRepresentableDigits()
      • createCopy

        public DecimalQuantity createCopy()
        Description copied from interface: DecimalQuantity
        Like 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

        public static DecimalQuantity fromExponentString​(java.lang.String num)
        Returns a DecimalQuantity after parsing the input string.
        Parameters:
        s - The String to parse
      • getVisibleFractionCount

        private static int getVisibleFractionCount​(java.lang.String value)
      • getDigitPos

        protected byte getDigitPos​(int position)
        Description copied from class: DecimalQuantity_AbstractBCD
        Returns a single digit from the BCD list. No internal state is changed by calling this method.
        Specified by:
        getDigitPos in class DecimalQuantity_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_AbstractBCD
        Sets the digit in the BCD list. This method only sets the digit; it is the caller's responsibility to call DecimalQuantity_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:
        setDigitPos in class DecimalQuantity_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.
      • readIntToBcd

        protected void readIntToBcd​(int n)
        Description copied from class: DecimalQuantity_AbstractBCD
        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.
        Specified by:
        readIntToBcd in class DecimalQuantity_AbstractBCD
      • readLongToBcd

        protected void readLongToBcd​(long n)
        Description copied from class: DecimalQuantity_AbstractBCD
        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.
        Specified by:
        readLongToBcd in class DecimalQuantity_AbstractBCD
      • readBigIntegerToBcd

        protected void readBigIntegerToBcd​(java.math.BigInteger n)
        Description copied from class: DecimalQuantity_AbstractBCD
        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.
        Specified by:
        readBigIntegerToBcd in class DecimalQuantity_AbstractBCD
      • ensureCapacity

        private void ensureCapacity()
        Ensure that a byte array of at least 40 digits is allocated.
      • ensureCapacity

        private void ensureCapacity​(int capacity)
      • switchStorage

        private void switchStorage()
        Switches the internal storage mechanism between the 64-bit long and the byte array.
      • checkHealth

        @Deprecated
        public java.lang.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:
        An error message if this instance is invalid, or null if this instance is healthy.
      • isUsingBytes

        @Deprecated
        public boolean isUsingBytes()
        Deprecated.
        This API is ICU internal only.
        Checks whether this DecimalQuantity_DualStorageBCD is 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

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • toNumberString

        private java.lang.String toNumberString()