public class XBDoubleFormat
extends java.lang.Object
XBDoubleFormat is used for formatting double/float values into decimal
strings.
Depending on the constructor arguments, an XBDoubleFormat may format strings
using exponential notation, decimal notation, or a mixture of these. These
options are explained below.
totalDigits: The maximum total number of digits to be displayed.
Pass -1 to let this be defaulted based on the datatype being formatted.
fractionDigits: The maximum number of fraction digits to be displayed.
Trailing zeros do not count. Pass -1 for unspecified.
fractionMinDigits: The minimum number of fraction digits to be displayed.
Trailing zeros are added if necessary. Values < 0 are ignored.
integerMaxDigits: The maximum number of integer digits to be displayed.
Pass -1 for unspecified.
integerMinDigits: The minimum number of integer digits to be displayed.
Leading zeros are added if necessary. Values < 0 are ignored.
expDigits: The minimum number of digits to use for the exponent. 0 means use
decimal notation. >=1 means use exponential notation. -1 means
"unspecified".
expSymbol: If decimal notation is chosen (expDigits = 0), large values are
handled in one of two ways:
if expSymbol = '0': trailing zeros in the integer part are allowed
otherwise: revert to exponential notation with minimal exponent value
expMinValue: minimum exponent value; <= Short.MIN_VALUE means "unspecified"
expMaxValue: maximum exponent value; >= Short.MAX_VALUE means "unspecified"
If exponential notation is chosen (using expDigits, expMinValue, or
expMaxValue), the exponent is decided using one of two methods:
1) based on the defined range (if expMinValue or expMaxValue are used)
2) based on the digits constraints (totalDigits, integerMaxDigits,
and fractionDigits).
Exponential notation "by range": The exponent is normalized, if possible,
subject to the given range.
Exponential notation "by digit constraints": The exponent is chosen so as to:
- use at least 1 integer digit
- avoid losing significant digits unnecessarily
- avoid using a negative exponent
- avoid needing leading integer zeros
If totalDigits - fractionDigits >= integerMaxDigits, integerMaxDigits
will appear in the integer part.
If integerMaxDigits = 1, the exponent is normalized.
Decimal notation: standard decimal notation, but see expSymbol, which
controls the behavior when totalDigits or integerMaxDigits are insufficient
for a decimal representation.
Mixed Notation: if neither exponential nor decimal notation is chosen
(ie, expMinValue, expMaxValue, and expDigits are "unspecified"), then
mixed notation is used (thus, this is the default). If 1 <= |value| < 10^10
decimal notation is used, otherwise exponential notation is used. If
totalDigits or integerMaxDigits are insufficient, trailing integer zeros
are used.
Thread safety: instances of this class are thread-safe and may be shared by
threads.