NumberFormatSI class
NumberFormatSI implements the International System of Units (SI) style conventions for displaying values of quantities. Specifically:
- Three-digit groups of numbers with more than four digits are separated by spaces instead of commas (for example, 299 792 458, not 299,792,458) to avoid confusion with the decimal marker in European literature. This spacing is also used to the right of the decimal marker (for example, 12 345.678 90).
- Uncertainty in the quantity's value may be optionally displayed... e.g., 1.234(11) or 1.234 +/- 0.011.
The value will be displayed in "computer scientific notation" (e.g., 1.3E9) if its exponent is less than -3 or greater than 6. These thresholds are arbitrary, but track with typical usage. If the exponent does not pass one of these thresholds then the number is simply displayed as a normal decimal number (e.g., 1 234.567 89).
The standard DecimalFormat class is unable to apply grouping to digits after the decimal. Therefore, this class directly extends NumberFormat and provides implementations for format and parse.
- Implementers
Constructors
- NumberFormatSI({bool unicode = false})
- Constructs an instance.
Properties
- currencyName ↔ String?
-
The name of the currency to print, in ISO 4217 form.
getter/setter pair
- currencySymbol → String
-
The symbol to be used when formatting this as currency.
no setter
- decimalDigits → int?
-
The number of decimal places to use when formatting.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- locale → String
-
Return the locale code in which we operate, e.g. 'en_US' or 'pt'.
no setter
- localeZero → int
-
The code point for the locale's zero digit.
no setter
- maximumFractionDigits ↔ int
-
getter/setter pair
- maximumIntegerDigits ↔ int
-
getter/setter pair
- maximumSignificantDigits ↔ int?
-
getter/setter pair
- minimumExponentDigits ↔ int
-
getter/setter pair
- minimumFractionDigits ↔ int
-
getter/setter pair
- minimumIntegerDigits ↔ int
-
getter/setter pair
- minimumSignificantDigits ↔ int?
-
getter/setter pair
- minimumSignificantDigitsStrict ↔ bool
-
Whether minimumSignificantDigits should cause trailing 0 in fraction part.
getter/setter pair
- multiplier → int
-
For percent and permille, what are we multiplying by in order to
get the printed value, e.g. 100 for percent.
no setter
- negativePrefix → String
-
Variables to determine how number printing behaves.
no setter
- negativeSuffix → String
-
no setter
- positivePrefix → String
-
no setter
- positiveSuffix → String
-
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- significantDigits ↔ int?
-
How many significant digits should we print.
getter/setter pair
- significantDigitsInUse ↔ bool
-
getter/setter pair
- symbols → NumberSymbols
-
Return the symbols which are used in our locale. Cache them to avoid
repeated lookup.
no setter
- unicode ↔ bool
-
Output in unicode (unicode thin spaces instead of regular ascii spaces).
getter/setter pair
Methods
-
adjustForExponent(
String str) → String - Subclasses should override if they wish to modify the number string to include an exponent and move the decimal point.
-
format(
dynamic value) → String -
value
is expected to be a Quantity, Number or num object. -
insertSpaces(
String str) → String - Returns a String with spaces added according to SI guidelines.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
parse(
String text) → num - Parse the number represented by the string. If it's not parseable, throws a FormatException.
-
parseWith<
R, P extends NumberParserBase< (R> >P parserGenerator(NumberFormat p1, String p2), String text) → R - Parse the number represented by the string using the parser created by the supplied parser generator. If it's not parseable, throws a FormatException.
-
simpleCurrencySymbol(
String currencyCode) → String -
Returns the simple currency symbol for given currency code, or
currencyCode
if no simple symbol is listed. -
toString(
) → String -
A string representation of this object.
inherited
-
tryParse(
String text) → num? -
Parse the number represented by the string. If it's not
parsable, returns
null
. -
tryParseWith<
R, P extends NumberParserBase< (R> >P parserGenerator(NumberFormat p1, String p2), String text) → R? -
Parse the number represented by the string using the parser created by the supplied parser generator. If it's not
parsable, returns
null
. -
turnOffGrouping(
) → void - Explicitly turn off any grouping (e.g. by thousands) in this format.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
removeInsignificantZeros(
String str) → String - Removes any zeros at the end of a number string that follow a decimal point (except for one that immediately follows the decimal point).