A private inner class that is similar in structure to ParseBase.Number. More...
Public Member Functions | |
| void | round (final int sigDigits) |
| Rounds to sigDigits significant digits. | |
| int | precision (int maxLength) |
| The number of significant digits shown if the string representation is compressed into the given length and shown in standard notation. | |
| int | scientificPrecision (int maxLength) |
| The number of significant digits shown if the string representation is compressed into the given length and shown in scientific notation. | |
| int | scientificBPrecision (int maxLength) |
| The number of significant digits shown if the string representation is compressed into the given length and shown in scientific (binary) notation. | |
| int | length () |
| The length of string that would be produced in standard notation. | |
| int | scientificLength () |
| The length of string that would be produced in scientific notation. | |
| int | exponentDigits () |
| Calculate the number of digits in the exponent. | |
| String | standard () |
| Produce a string representing the number without using scientific notation. | |
| String | scientific () |
| Produce a string representing the number using scientific notation. | |
| String | scientificB () |
| Produce a string representing the binary number using scientific notation. | |
| int | scientificBLength () |
| The length of string that would be produced in scientific notation, changing a binary to 2x{decimal integer}. | |
Public Attributes | |
| boolean | negative |
| Is number negative? | |
| java.util.Vector< Integer > | digits |
| Representation of significand digits as integers in correct base. | |
| boolean | exponentNegative |
| Is exponent negative? | |
| java.util.Vector< Integer > | exponentDigits |
| Representation of exponent digits as integers in correct base. | |
| int | exponent |
| Value of the exponent. | |
| boolean | infinity |
| Is number infinite? | |
| boolean | NaN |
| Is number not a number? | |
| boolean | zero |
| Is number zero? Useful so we can avoid overflow in some methods. | |
| int | base |
| The base as an integer. | |
Static Public Attributes | |
| static final long | BIAS = 1023 |
| Standard constant for IEEE 754 doubles. | |
| static final long | E_MAX = 1023 |
| Standard constant for IEEE 754 doubles. | |
| static final long | E_MIN = -1022 |
| Standard constant for IEEE 754 doubles. | |
Package Functions | |
| DoubleFormat (double number, Base base) | |
| The constructor takes a double and a base. | |
Private Member Functions | |
| void | formatDec (double number) |
| This method handles formatting decimals. | |
| void | formatHex (double number) |
| This method handles formatting hexadecimals. | |
| void | formatOct (double number) |
| This method handles formatting octals. | |
| void | formatBin (double number) |
| This method handles formatting binary numbers. | |
Static Private Member Functions | |
| static int | getInt (char c) |
| This is effectively the reverse of getDigit(). | |
| static char | getDigit (int d) |
| We need to know how to represent integers up to 15 as char. | |
A private inner class that is similar in structure to ParseBase.Number.
It is used by Format to represent a double in a form from whch the digits can be extracted as characters.
| jscicalc.complex.Format.DoubleFormat.DoubleFormat | ( | double | number, | |
| Base | base | |||
| ) | [package] |
The constructor takes a double and a base.
| number | The double we want to format | |
| base | The Base |
References jscicalc.complex.Format.DoubleFormat.digits, jscicalc.complex.Format.DoubleFormat.exponentDigits(), jscicalc.complex.Format.DoubleFormat.formatBin(), jscicalc.complex.Format.DoubleFormat.formatDec(), jscicalc.complex.Format.DoubleFormat.formatHex(), jscicalc.complex.Format.DoubleFormat.formatOct(), jscicalc.complex.Format.DoubleFormat.infinity, jscicalc.complex.Format.DoubleFormat.NaN, and jscicalc.complex.Format.DoubleFormat.zero.
Calculate the number of digits in the exponent.
This is used to help decide when to use scientific notation.
References jscicalc.complex.Format.z.
Referenced by jscicalc.complex.Format.DoubleFormat.DoubleFormat(), jscicalc.complex.Format.DoubleFormat.formatBin(), jscicalc.complex.Format.DoubleFormat.formatDec(), jscicalc.complex.Format.DoubleFormat.formatHex(), jscicalc.complex.Format.DoubleFormat.formatOct(), jscicalc.complex.Format.DoubleFormat.round(), jscicalc.complex.Format.DoubleFormat.scientific(), and jscicalc.complex.Format.DoubleFormat.scientificLength().
| void jscicalc.complex.Format.DoubleFormat.formatBin | ( | double | number | ) | [private] |
This method handles formatting binary numbers.
| number | The double to format |
References jscicalc.complex.Format.DoubleFormat.BIAS, jscicalc.complex.Format.DoubleFormat.digits, jscicalc.complex.Format.DoubleFormat.E_MIN, jscicalc.complex.Format.DoubleFormat.exponent, jscicalc.complex.Format.DoubleFormat.exponentDigits(), jscicalc.complex.Format.DoubleFormat.exponentNegative, and jscicalc.complex.Format.DoubleFormat.negative.
Referenced by jscicalc.complex.Format.DoubleFormat.DoubleFormat().
| void jscicalc.complex.Format.DoubleFormat.formatDec | ( | double | number | ) | [private] |
This method handles formatting decimals.
| number | The double to format |
References jscicalc.complex.Format.DoubleFormat.digits, jscicalc.complex.Format.DoubleFormat.exponent, jscicalc.complex.Format.DoubleFormat.exponentDigits(), jscicalc.complex.Format.DoubleFormat.exponentNegative, jscicalc.complex.Format.DoubleFormat.getInt(), jscicalc.complex.Format.DoubleFormat.infinity, jscicalc.complex.Format.DoubleFormat.NaN, jscicalc.complex.Format.DoubleFormat.negative, and jscicalc.complex.Format.DoubleFormat.zero.
Referenced by jscicalc.complex.Format.DoubleFormat.DoubleFormat().
| void jscicalc.complex.Format.DoubleFormat.formatHex | ( | double | number | ) | [private] |
This method handles formatting hexadecimals.
| number | The double to format |
References jscicalc.complex.Format.DoubleFormat.BIAS, jscicalc.complex.Format.DoubleFormat.digits, jscicalc.complex.Format.DoubleFormat.E_MIN, jscicalc.complex.Format.DoubleFormat.exponent, jscicalc.complex.Format.DoubleFormat.exponentDigits(), jscicalc.complex.Format.DoubleFormat.exponentNegative, and jscicalc.complex.Format.DoubleFormat.negative.
Referenced by jscicalc.complex.Format.DoubleFormat.DoubleFormat().
| void jscicalc.complex.Format.DoubleFormat.formatOct | ( | double | number | ) | [private] |
This method handles formatting octals.
| number | The double to format |
References jscicalc.complex.Format.DoubleFormat.BIAS, jscicalc.complex.Format.DoubleFormat.digits, jscicalc.complex.Format.DoubleFormat.E_MIN, jscicalc.complex.Format.DoubleFormat.exponent, jscicalc.complex.Format.DoubleFormat.exponentDigits(), jscicalc.complex.Format.DoubleFormat.exponentNegative, and jscicalc.complex.Format.DoubleFormat.negative.
Referenced by jscicalc.complex.Format.DoubleFormat.DoubleFormat().
| static char jscicalc.complex.Format.DoubleFormat.getDigit | ( | int | d | ) | [static, private] |
We need to know how to represent integers up to 15 as char.
This function does it.
| d | An integer (should be in range 0–15) |
Referenced by jscicalc.complex.Format.DoubleFormat.scientific(), and jscicalc.complex.Format.DoubleFormat.standard().
| static int jscicalc.complex.Format.DoubleFormat.getInt | ( | char | c | ) | [static, private] |
This is effectively the reverse of getDigit().
We use it when extracting digits from Double.toString().
| c | A char corresponding to a digit |
Referenced by jscicalc.complex.Format.DoubleFormat.formatDec().
| int jscicalc.complex.Format.DoubleFormat.length | ( | ) |
The length of string that would be produced in standard notation.
References jscicalc.complex.Format.DoubleFormat.digits, jscicalc.complex.Format.DoubleFormat.exponent, jscicalc.complex.Format.DoubleFormat.exponentNegative, jscicalc.complex.Format.DoubleFormat.infinity, jscicalc.complex.Format.DoubleFormat.NaN, jscicalc.complex.Format.DoubleFormat.negative, and jscicalc.complex.Format.DoubleFormat.zero.
Referenced by jscicalc.complex.Format.DoubleFormat.precision(), jscicalc.complex.Format.DoubleFormat.scientificBPrecision(), jscicalc.complex.Format.DoubleFormat.scientificLength(), and jscicalc.complex.Format.DoubleFormat.scientificPrecision().
| int jscicalc.complex.Format.DoubleFormat.precision | ( | int | maxLength | ) |
The number of significant digits shown if the string representation is compressed into the given length and shown in standard notation.
The function returns zero if the string cannot be compressed that much.
| maxLength | The desired maximum length |
References jscicalc.complex.Format.DoubleFormat.digits, jscicalc.complex.Format.DoubleFormat.exponent, jscicalc.complex.Format.DoubleFormat.exponentNegative, jscicalc.complex.Format.DoubleFormat.infinity, jscicalc.complex.Format.DoubleFormat.length(), jscicalc.complex.Format.DoubleFormat.NaN, jscicalc.complex.Format.DoubleFormat.negative, and jscicalc.complex.Format.DoubleFormat.zero.
Referenced by jscicalc.complex.Format.formatStandard().
| void jscicalc.complex.Format.DoubleFormat.round | ( | final int | sigDigits | ) |
Rounds to sigDigits significant digits.
We round 0.5 (or 0.1, 0.4, 0.8) up to nearest whole and get an aswer with sigDigits digits in it.
| sigDigits | The desired number of significant digits |
References jscicalc.complex.Format.DoubleFormat.base, jscicalc.complex.Format.DoubleFormat.digits, jscicalc.complex.Format.DoubleFormat.exponentDigits(), and jscicalc.complex.Format.DoubleFormat.exponentNegative.
Referenced by jscicalc.complex.Format.formatStandard().
| String jscicalc.complex.Format.DoubleFormat.scientific | ( | ) |
Produce a string representing the number using scientific notation.
All significant digits are used; so use round() to shorten if necessary.
References jscicalc.complex.Format.DoubleFormat.digits, jscicalc.complex.Format.DoubleFormat.exponent, jscicalc.complex.Format.DoubleFormat.exponentDigits(), jscicalc.complex.Format.DoubleFormat.exponentNegative, jscicalc.complex.Format.DoubleFormat.getDigit(), jscicalc.complex.Format.DoubleFormat.infinity, jscicalc.complex.Format.DoubleFormat.NaN, jscicalc.complex.Format.DoubleFormat.negative, jscicalc.complex.Format.z, and jscicalc.complex.Format.DoubleFormat.zero.
Referenced by jscicalc.complex.Format.formatStandard(), jscicalc.complex.Format.DoubleFormat.scientificB(), and jscicalc.complex.Format.DoubleFormat.scientificBLength().
| String jscicalc.complex.Format.DoubleFormat.scientificB | ( | ) |
Produce a string representing the binary number using scientific notation.
All significant digits are used; so use round() to shorten if necessary. The exponent is rewritten as x2{decimal integer} if number is binary
References jscicalc.complex.Format.DoubleFormat.base, and jscicalc.complex.Format.DoubleFormat.scientific().
Referenced by jscicalc.complex.Format.formatStandard().
| int jscicalc.complex.Format.DoubleFormat.scientificBLength | ( | ) |
The length of string that would be produced in scientific notation, changing a binary to 2x{decimal integer}.
References jscicalc.complex.Format.DoubleFormat.base, jscicalc.complex.Format.DoubleFormat.scientific(), and jscicalc.complex.Format.DoubleFormat.scientificLength().
Referenced by jscicalc.complex.Format.DoubleFormat.scientificBPrecision().
| int jscicalc.complex.Format.DoubleFormat.scientificBPrecision | ( | int | maxLength | ) |
The number of significant digits shown if the string representation is compressed into the given length and shown in scientific (binary) notation.
The function returns zero if the string cannot be compressed that much.
| maxLength | The desired maximum length |
References jscicalc.complex.Format.DoubleFormat.digits, jscicalc.complex.Format.DoubleFormat.infinity, jscicalc.complex.Format.DoubleFormat.length(), jscicalc.complex.Format.DoubleFormat.NaN, jscicalc.complex.Format.DoubleFormat.negative, jscicalc.complex.Format.DoubleFormat.scientificBLength(), jscicalc.complex.Format.z, and jscicalc.complex.Format.DoubleFormat.zero.
Referenced by jscicalc.complex.Format.formatStandard().
| int jscicalc.complex.Format.DoubleFormat.scientificLength | ( | ) |
The length of string that would be produced in scientific notation.
References jscicalc.complex.Format.DoubleFormat.digits, jscicalc.complex.Format.DoubleFormat.exponentDigits(), jscicalc.complex.Format.DoubleFormat.exponentNegative, jscicalc.complex.Format.DoubleFormat.infinity, jscicalc.complex.Format.DoubleFormat.length(), jscicalc.complex.Format.DoubleFormat.NaN, jscicalc.complex.Format.DoubleFormat.negative, jscicalc.complex.Format.z, and jscicalc.complex.Format.DoubleFormat.zero.
Referenced by jscicalc.complex.Format.DoubleFormat.scientificBLength(), and jscicalc.complex.Format.DoubleFormat.scientificPrecision().
| int jscicalc.complex.Format.DoubleFormat.scientificPrecision | ( | int | maxLength | ) |
The number of significant digits shown if the string representation is compressed into the given length and shown in scientific notation.
The function returns zero if the string cannot be compressed that much.
| maxLength | The desired maximum length |
References jscicalc.complex.Format.DoubleFormat.digits, jscicalc.complex.Format.DoubleFormat.infinity, jscicalc.complex.Format.DoubleFormat.length(), jscicalc.complex.Format.DoubleFormat.NaN, jscicalc.complex.Format.DoubleFormat.negative, jscicalc.complex.Format.DoubleFormat.scientificLength(), jscicalc.complex.Format.z, and jscicalc.complex.Format.DoubleFormat.zero.
Referenced by jscicalc.complex.Format.formatStandard().
| String jscicalc.complex.Format.DoubleFormat.standard | ( | ) |
Produce a string representing the number without using scientific notation.
This can produce very long strings.
References jscicalc.complex.Format.DoubleFormat.digits, jscicalc.complex.Format.DoubleFormat.exponent, jscicalc.complex.Format.DoubleFormat.exponentNegative, jscicalc.complex.Format.DoubleFormat.getDigit(), jscicalc.complex.Format.DoubleFormat.infinity, jscicalc.complex.Format.DoubleFormat.NaN, jscicalc.complex.Format.DoubleFormat.negative, jscicalc.complex.Format.z, and jscicalc.complex.Format.DoubleFormat.zero.
Referenced by jscicalc.complex.Format.formatStandard().
The base as an integer.
Referenced by jscicalc.complex.Format.DoubleFormat.round(), jscicalc.complex.Format.DoubleFormat.scientificB(), and jscicalc.complex.Format.DoubleFormat.scientificBLength().
final long jscicalc.complex.Format.DoubleFormat.BIAS = 1023 [static] |
Standard constant for IEEE 754 doubles.
Referenced by jscicalc.complex.Format.DoubleFormat.formatBin(), jscicalc.complex.Format.DoubleFormat.formatHex(), and jscicalc.complex.Format.DoubleFormat.formatOct().
| java.util.Vector<Integer> jscicalc.complex.Format.DoubleFormat.digits |
Representation of significand digits as integers in correct base.
Referenced by jscicalc.complex.Format.DoubleFormat.DoubleFormat(), jscicalc.complex.Format.DoubleFormat.formatBin(), jscicalc.complex.Format.DoubleFormat.formatDec(), jscicalc.complex.Format.DoubleFormat.formatHex(), jscicalc.complex.Format.DoubleFormat.formatOct(), jscicalc.complex.Format.DoubleFormat.length(), jscicalc.complex.Format.DoubleFormat.precision(), jscicalc.complex.Format.DoubleFormat.round(), jscicalc.complex.Format.DoubleFormat.scientific(), jscicalc.complex.Format.DoubleFormat.scientificBPrecision(), jscicalc.complex.Format.DoubleFormat.scientificLength(), jscicalc.complex.Format.DoubleFormat.scientificPrecision(), and jscicalc.complex.Format.DoubleFormat.standard().
final long jscicalc.complex.Format.DoubleFormat.E_MAX = 1023 [static] |
Standard constant for IEEE 754 doubles.
final long jscicalc.complex.Format.DoubleFormat.E_MIN = -1022 [static] |
Standard constant for IEEE 754 doubles.
Referenced by jscicalc.complex.Format.DoubleFormat.formatBin(), jscicalc.complex.Format.DoubleFormat.formatHex(), and jscicalc.complex.Format.DoubleFormat.formatOct().
Value of the exponent.
Referenced by jscicalc.complex.Format.DoubleFormat.formatBin(), jscicalc.complex.Format.DoubleFormat.formatDec(), jscicalc.complex.Format.DoubleFormat.formatHex(), jscicalc.complex.Format.DoubleFormat.formatOct(), jscicalc.complex.Format.DoubleFormat.length(), jscicalc.complex.Format.DoubleFormat.precision(), jscicalc.complex.Format.DoubleFormat.scientific(), and jscicalc.complex.Format.DoubleFormat.standard().
| java.util.Vector<Integer> jscicalc.complex.Format.DoubleFormat.exponentDigits |
Representation of exponent digits as integers in correct base.
Is exponent negative?
Referenced by jscicalc.complex.Format.DoubleFormat.formatBin(), jscicalc.complex.Format.DoubleFormat.formatDec(), jscicalc.complex.Format.DoubleFormat.formatHex(), jscicalc.complex.Format.DoubleFormat.formatOct(), jscicalc.complex.Format.DoubleFormat.length(), jscicalc.complex.Format.DoubleFormat.precision(), jscicalc.complex.Format.DoubleFormat.round(), jscicalc.complex.Format.DoubleFormat.scientific(), jscicalc.complex.Format.DoubleFormat.scientificLength(), and jscicalc.complex.Format.DoubleFormat.standard().
Is number infinite?
Referenced by jscicalc.complex.Format.DoubleFormat.DoubleFormat(), jscicalc.complex.Format.DoubleFormat.formatDec(), jscicalc.complex.Format.DoubleFormat.length(), jscicalc.complex.Format.DoubleFormat.precision(), jscicalc.complex.Format.DoubleFormat.scientific(), jscicalc.complex.Format.DoubleFormat.scientificBPrecision(), jscicalc.complex.Format.DoubleFormat.scientificLength(), jscicalc.complex.Format.DoubleFormat.scientificPrecision(), and jscicalc.complex.Format.DoubleFormat.standard().
Is number not a number?
Referenced by jscicalc.complex.Format.DoubleFormat.DoubleFormat(), jscicalc.complex.Format.DoubleFormat.formatDec(), jscicalc.complex.Format.DoubleFormat.length(), jscicalc.complex.Format.DoubleFormat.precision(), jscicalc.complex.Format.DoubleFormat.scientific(), jscicalc.complex.Format.DoubleFormat.scientificBPrecision(), jscicalc.complex.Format.DoubleFormat.scientificLength(), jscicalc.complex.Format.DoubleFormat.scientificPrecision(), and jscicalc.complex.Format.DoubleFormat.standard().
Is number negative?
Referenced by jscicalc.complex.Format.DoubleFormat.formatBin(), jscicalc.complex.Format.DoubleFormat.formatDec(), jscicalc.complex.Format.DoubleFormat.formatHex(), jscicalc.complex.Format.DoubleFormat.formatOct(), jscicalc.complex.Format.DoubleFormat.length(), jscicalc.complex.Format.DoubleFormat.precision(), jscicalc.complex.Format.DoubleFormat.scientific(), jscicalc.complex.Format.DoubleFormat.scientificBPrecision(), jscicalc.complex.Format.DoubleFormat.scientificLength(), jscicalc.complex.Format.DoubleFormat.scientificPrecision(), and jscicalc.complex.Format.DoubleFormat.standard().
Is number zero? Useful so we can avoid overflow in some methods.
Referenced by jscicalc.complex.Format.DoubleFormat.DoubleFormat(), jscicalc.complex.Format.DoubleFormat.formatDec(), jscicalc.complex.Format.DoubleFormat.length(), jscicalc.complex.Format.DoubleFormat.precision(), jscicalc.complex.Format.DoubleFormat.scientific(), jscicalc.complex.Format.DoubleFormat.scientificBPrecision(), jscicalc.complex.Format.DoubleFormat.scientificLength(), jscicalc.complex.Format.DoubleFormat.scientificPrecision(), and jscicalc.complex.Format.DoubleFormat.standard().
1.7.1