0 - 10 representing an unsigned integer with leading and trailing zeros
removed, andExamples
| Double | Negative | Digits | Exponent |
|---|---|---|---|
| 0.0 | false | [0] | 0 |
| 1.2 | false | [1, 2] | -1 |
| -0.00971 | true | [9, 7, 1] | -5 |
| 56300 | true | [5, 6, 3] | 2 |
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static interface | ParsedDecimal.
Interface containing values used during string formatting. |
| Modifier and Type | Field and Description |
|---|---|
| private static final int | DECIMAL_RADIX
Radix for decimal numbers. |
| private static final char | DECIMAL_SEP_CHAR
Decimal separator character. |
| pack-priv int | digitCount
Number of digits used in the digits array; not necessarily equal to the length. |
| pack-priv final int[] | digits
Array containing the significant decimal digits for the value. |
| private static final int | ENG_EXPONENT_MOD
Number that exponents in engineering format must be a multiple of. |
| pack-priv int | exponent
Exponent for the value. |
| private static final char | EXPONENT_CHAR
Exponent character. |
| private static final char | MINUS_CHAR
Minus sign character. |
| pack-priv final boolean | negative
True if the value is negative. |
| private char[] | outputChars
Output buffer for use in creating string representations. |
| private int | outputIdx
Output buffer index. |
| private static final int | ROUND_CENTER
Center value used when rounding. |
| private static final int | THOUSANDS_GROUP_SIZE
Number of characters in thousands groupings. |
| private static final char | ZERO_CHAR
Zero digit character. |
| Access | Constructor and Description |
|---|---|
| private | ParsedDecimal(final boolean
true if the value is negative.array containing significant digits. digits, final int number of digits used from the digitCount, final int digits array.exponent value. exponent)Constructs a new instance from its parts. |
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| private void | append(final char[]
characters to append. chars)Appends the given character array directly to the output buffer. |
| private void | appendFraction(final int
number of zeros to add after the decimal point and before the first significant digit. zeroCount, final int significant digit start index. startIdx, final ParsedDecimal.format options. optsAppends the fractional component of the number to the current output buffer. |
| private void | appendLocalizedDigit(final int
digit to append. n, final char[] character array containing localized versions of the digits digitChars)0-9 in that order.Appends the localized representation of the digit |
| private int | Returns: number of digits fromdigits appended to the output buffer.total number of digits required to the left of the decimal point. wholeCount, final ParsedDecimal.format options. optsAppends the whole number portion of this value to the output buffer. |
| private int | Returns: number of digits fromdigits appended to the output buffer.total number of digits required to the right of the decimal point wholeCount, final ParsedDecimal.format options. optsAppends the whole number portion of this value to the output buffer, adding thousands separators as needed. |
| private static int | Returns: numeric value of the digit character, ex: '1' = 1.digit character. ch)Gets the numeric value of the given digit character. |
| public static ParsedDecimal | Returns: a new instance containing the parsed components of the given double value.double value. d)Constructs a new instance from the given double value. |
| private int | Returns: number of characters required for the digit portion of a string representation of this value.decimal point position relative to the decimalPos, final ParsedDecimal.digits array.format options. optsGets the number of characters required for the digit portion of a string representation of this value. |
| public int | |
| private int | Returns: number of characters in the plain string representation of this value, created using the given parameters.decimal position relative to the decimalPos, final ParsedDecimal.digits array.format options. optsGets the number of characters required to create a plain format representation of this value. |
| public int | Returns: the exponent that would be used when representing this number in scientific notation.Gets the exponent that would be used when representing this number in scientific notation (i.e., with a single non-zero digit in front of the decimal point). |
| pack-priv boolean | |
| public void | maxPrecision(final int
maximum number of significant digits to include. precision)Ensures that this instance has at most the given number of significant digits (i.e. precision). |
| private String | |
| private static int | Returns: parsed exponent value.character array to parse a double exponent value from. chars, final int start index. start)Parses a double exponent value from |
| private void | |
| private boolean | Returns: true if a grouping separator should be added.whole digit character position, with values starting at 1 and increasing from right to left. pos)Returns |
| public void | round(final int
exponent defining the decimal place to round to. roundExponent)Rounds the instance to the given decimal exponent position using |
| private void | roundUp(final int
target number of digits; must be greater than zero and less than the current number of digits. count)Rounds the value up to the given number of digits. |
| private void | setSingleDigitValue(final int
digit value. digit, final int new exponent value. newExponent)Sets the value of this instance to a single digit with the given exponent. |
| private boolean | Returns: true if the formatted string should include the exponent field.exponent of the formatted result. targetExponent, final ParsedDecimal.format options. optsReturns |
| private boolean | Returns: true if a minus sign should be included in the output.format options. optsReturns |
| private boolean | Returns: true if a rounding operation for the given number of digits should round up.number of digits to round to; must be greater than zero and less than the current number of digits. count)Returns |
| public String | Returns: value in engineering format.format options. optsReturns a string representation of this value in engineering notation. |
| public String | Returns: value in plain format.format options. optsReturns a string representation of this value with no exponent field. |
| public String | Returns: value in scientific format.format options. optsReturns a string representation of this value in scientific notation. |
| private String | Returns: value in scientific format.decimal position relative to the decimalPos, final ParsedDecimal.digits array; this value is expected to be greater than 0.format options. optsReturns a string representation of the value in scientific notation using the given decimal point position. |
| private void | truncate(final int
number of digits; must be greater than zero and less than the current number of digits. count)Truncates the value to the given number of digits. |
| DECIMAL_RADIX | back to summary |
|---|---|
| private static final int DECIMAL_RADIX Radix for decimal numbers. | |
| DECIMAL_SEP_CHAR | back to summary |
|---|---|
| private static final char DECIMAL_SEP_CHAR Decimal separator character. | |
| digitCount | back to summary |
|---|---|
| pack-priv int digitCount Number of digits used in the digits array; not necessarily equal to the length. | |
| digits | back to summary |
|---|---|
| pack-priv final int[] digits Array containing the significant decimal digits for the value. | |
| ENG_EXPONENT_MOD | back to summary |
|---|---|
| private static final int ENG_EXPONENT_MOD Number that exponents in engineering format must be a multiple of. | |
| exponent | back to summary |
|---|---|
| pack-priv int exponent Exponent for the value. | |
| EXPONENT_CHAR | back to summary |
|---|---|
| private static final char EXPONENT_CHAR Exponent character. | |
| MINUS_CHAR | back to summary |
|---|---|
| private static final char MINUS_CHAR Minus sign character. | |
| negative | back to summary |
|---|---|
| pack-priv final boolean negative True if the value is negative. | |
| outputChars | back to summary |
|---|---|
| private char[] outputChars Output buffer for use in creating string representations. | |
| outputIdx | back to summary |
|---|---|
| private int outputIdx Output buffer index. | |
| ROUND_CENTER | back to summary |
|---|---|
| private static final int ROUND_CENTER Center value used when rounding. | |
| THOUSANDS_GROUP_SIZE | back to summary |
|---|---|
| private static final int THOUSANDS_GROUP_SIZE Number of characters in thousands groupings. | |
| ZERO_CHAR | back to summary |
|---|---|
| private static final char ZERO_CHAR Zero digit character. | |
| ParsedDecimal | back to summary |
|---|---|
| private ParsedDecimal(final boolean negative, final int[] digits, final int digitCount, final int exponent) Constructs a new instance from its parts.
| |
| append | back to summary |
|---|---|
| private void append(final char ch) Appends the given character to the output buffer.
| |
| append | back to summary |
|---|---|
| private void append(final char[] chars) Appends the given character array directly to the output buffer.
| |
| appendFraction | back to summary |
|---|---|
| private void appendFraction(final int zeroCount, final int startIdx, final ParsedDecimal. Appends the fractional component of the number to the current output buffer.
| |
| appendLocalizedDigit | back to summary |
|---|---|
| private void appendLocalizedDigit(final int n, final char[] digitChars) Appends the localized representation of the digit
| |
| appendWhole | back to summary |
|---|---|
| private int appendWhole(final int wholeCount, final ParsedDecimal. Appends the whole number portion of this value to the output buffer. No thousands separators are added.
| |
| appendWholeGrouped | back to summary |
|---|---|
| private int appendWholeGrouped(final int wholeCount, final ParsedDecimal. Appends the whole number portion of this value to the output buffer, adding thousands separators as needed.
| |
| digitValue | back to summary |
|---|---|
| private static int digitValue(final char ch) Gets the numeric value of the given digit character. No validation of the character type is performed.
| |
| from | back to summary |
|---|---|
| public static ParsedDecimal from(final double d) Constructs a new instance from the given double value.
| |
| getDigitStringSize | back to summary |
|---|---|
| private int getDigitStringSize(final int decimalPos, final ParsedDecimal. Gets the number of characters required for the digit portion of a string representation of this value. This excludes any exponent or thousands groupings characters.
| |
| getExponent | back to summary |
|---|---|
| public int getExponent() Gets the exponent value. This exponent produces a floating point value with the correct magnitude when applied to the internal unsigned integer.
| |
| getPlainStringSize | back to summary |
|---|---|
| private int getPlainStringSize(final int decimalPos, final ParsedDecimal. Gets the number of characters required to create a plain format representation of this value.
| |
| getScientificExponent | back to summary |
|---|---|
| public int getScientificExponent() Gets the exponent that would be used when representing this number in scientific notation (i.e., with a single non-zero digit in front of the decimal point).
| |
| isZero | back to summary |
|---|---|
| pack-priv boolean isZero() Tests
| |
| maxPrecision | back to summary |
|---|---|
| public void maxPrecision(final int precision) Ensures that this instance has at most the given number of significant digits (i.e. precision). If this instance already has a precision less
than or equal to the argument, nothing is done. If the given precision requires a reduction in the number of digits, then the value is rounded using
| |
| outputString | back to summary |
|---|---|
| private String outputString() Gets the output buffer as a string.
| |
| parseExponent | back to summary |
|---|---|
| private static int parseExponent(final char[] chars, final int start) Parses a double exponent value from
| |
| prepareOutput | back to summary |
|---|---|
| private void prepareOutput(final int size) Prepares the output buffer for a string of the given size.
| |
| requiresGroupingSeparatorAfterPosition | back to summary |
|---|---|
| private boolean requiresGroupingSeparatorAfterPosition(final int pos) Returns
| |
| round | back to summary |
|---|---|
| public void round(final int roundExponent) Rounds the instance to the given decimal exponent position using
| |
| roundUp | back to summary |
|---|---|
| private void roundUp(final int count) Rounds the value up to the given number of digits.
| |
| setSingleDigitValue | back to summary |
|---|---|
| private void setSingleDigitValue(final int digit, final int newExponent) Sets the value of this instance to a single digit with the given exponent. The sign of the value is retained.
| |
| shouldIncludeExponent | back to summary |
|---|---|
| private boolean shouldIncludeExponent(final int targetExponent, final ParsedDecimal. Returns
| |
| shouldIncludeMinus | back to summary |
|---|---|
| private boolean shouldIncludeMinus(final ParsedDecimal. Returns
| |
| shouldRoundUp | back to summary |
|---|---|
| private boolean shouldRoundUp(final int count) Returns
| |
| toEngineeringString | back to summary |
|---|---|
| public String toEngineeringString(final ParsedDecimal. Returns a string representation of this value in engineering notation. This is similar to For example: 0 = "0.0" 10 = "10.0" 1e-6 = "1.0E-6" 1e11 = "100.0E9"
| |
| toPlainString | back to summary |
|---|---|
| public String toPlainString(final ParsedDecimal. Returns a string representation of this value with no exponent field. For example: 10 = "10.0" 1e-6 = "0.000001" 1e11 = "100000000000.0"
| |
| toScientificString | back to summary |
|---|---|
| public String toScientificString(final ParsedDecimal. Returns a string representation of this value in scientific notation. For example: 0 = "0.0" 10 = "1.0E1" 1e-6 = "1.0E-6" 1e11 = "1.0E11"
| |
| toScientificString | back to summary |
|---|---|
| private String toScientificString(final int decimalPos, final ParsedDecimal. Returns a string representation of the value in scientific notation using the given decimal point position.
| |
| truncate | back to summary |
|---|---|
| private void truncate(final int count) Truncates the value to the given number of digits.
| |
| Modifier and Type | Method and Description |
|---|---|
| public char | |
| public char[] | Returns: array containing the digit characters 0-9.Gets an array containing the localized digit characters 0-9 in that order. |
| public char[] | Returns: exponent separator as an array of characters.Gets the exponent separator as an array of characters. |
| public char | Returns: character used to separate thousands groupings.Gets the character used to separate thousands groupings. |
| public char | |
| public boolean | Returns: true if exponent values should always be included.Return |
| public boolean | Returns: true if thousand should be grouped.Return |
| public boolean | Returns: true if fraction placeholders should be included.Return |
| public boolean | Returns: true if the minus zero string should be allowed.Return |
| getDecimalSeparator | back to summary |
|---|---|
| public char getDecimalSeparator() Gets the decimal separator character.
| |
| getDigits | back to summary |
|---|---|
| public char[] getDigits() Gets an array containing the localized digit characters 0-9 in that order. This string must be non-null and have a length of 10.
| |
| getExponentSeparatorChars | back to summary |
|---|---|
| public char[] getExponentSeparatorChars() Gets the exponent separator as an array of characters.
| |
| getGroupingSeparator | back to summary |
|---|---|
| public char getGroupingSeparator() Gets the character used to separate thousands groupings.
| |
| getMinusSign | back to summary |
|---|---|
| public char getMinusSign() Gets the minus sign character.
| |
| isAlwaysIncludeExponent | back to summary |
|---|---|
| public boolean isAlwaysIncludeExponent() Return
| |
| isGroupThousands | back to summary |
|---|---|
| public boolean isGroupThousands() Return
| |
| isIncludeFractionPlaceholder | back to summary |
|---|---|
| public boolean isIncludeFractionPlaceholder() Return
| |
| isSignedZero | back to summary |
|---|---|
| public boolean isSignedZero() Return
| |