Package | mx.formatters |
Class | public class NumberBase |
See also
Property | Defined by | ||
---|---|---|---|
decimalSeparatorFrom : String
Decimal separator character to use
when parsing an input String.
| NumberBase | ||
decimalSeparatorTo : String
Decimal separator character to use
when outputting formatted decimal numbers.
| NumberBase | ||
isValid : Boolean = false
If
true , the format succeeded,
otherwise it is false . | NumberBase | ||
thousandsSeparatorFrom : String
Character to use as the thousands separator
in the input String.
| NumberBase | ||
thousandsSeparatorTo : String
Character to use as the thousands separator
in the output String.
| NumberBase |
Method | Defined by | ||
---|---|---|---|
NumberBase(decimalSeparatorFrom:String = ".", thousandsSeparatorFrom:String = ",", decimalSeparatorTo:String = ".", thousandsSeparatorTo:String = ",")
Constructor.
| NumberBase | ||
formatDecimal(value:String):String
Formats a number by replacing the default decimal separator, ".",
with the decimal separator specified by
decimalSeparatorTo . | NumberBase | ||
formatNegative(value:String, useSign:Boolean):String
Formats a negative number with either a minus sign (-)
or parentheses ().
| NumberBase | ||
formatPrecision(value:String, precision:int):String
Formats a number by setting its decimal precision by using
the
decimalSeparatorTo property as the decimal separator. | NumberBase | ||
formatRounding(value:String, roundType:String):String
Formats a number by rounding it.
| NumberBase | ||
formatRoundingWithPrecision(value:String, roundType:String, precision:int):String
Formats a number by rounding it and setting the decimal precision.
| NumberBase | ||
formatThousands(value:String):String
Formats a number by using
the
thousandsSeparatorTo property as the thousands separator
and the decimalSeparatorTo property as the decimal separator. | NumberBase | ||
parseNumberString(str:String):String
Extracts a number from a formatted String.
| NumberBase |
decimalSeparatorFrom | property |
public var decimalSeparatorFrom:String
Decimal separator character to use when parsing an input String.
The default value is "."
.
decimalSeparatorTo | property |
public var decimalSeparatorTo:String
Decimal separator character to use when outputting formatted decimal numbers.
The default value is "."
.
isValid | property |
public var isValid:Boolean = false
If true
, the format succeeded,
otherwise it is false
.
thousandsSeparatorFrom | property |
public var thousandsSeparatorFrom:String
Character to use as the thousands separator in the input String.
The default value is ","
.
thousandsSeparatorTo | property |
public var thousandsSeparatorTo:String
Character to use as the thousands separator in the output String.
The default value is ","
.
NumberBase | () | constructor |
public function NumberBase(decimalSeparatorFrom:String = ".", thousandsSeparatorFrom:String = ",", decimalSeparatorTo:String = ".", thousandsSeparatorTo:String = ",")
Constructor.
ParametersdecimalSeparatorFrom:String (default = ". ") — Decimal separator to use
when parsing an input String.
|
|
thousandsSeparatorFrom:String (default = ", ") — Character to use
as the thousands separator in the input String.
|
|
decimalSeparatorTo:String (default = ". ") — Decimal separator character to use
when outputting formatted decimal numbers.
|
|
thousandsSeparatorTo:String (default = ", ") — Character to use
as the thousands separator in the output String.
|
formatDecimal | () | method |
public function formatDecimal(value:String):String
Formats a number by replacing the default decimal separator, ".",
with the decimal separator specified by decimalSeparatorTo
.
value:String — The String value of the Number
(formatted American style ####.##).
|
String — String representation of the input where "." is replaced
with the decimal formatting character.
|
formatNegative | () | method |
public function formatNegative(value:String, useSign:Boolean):String
Formats a negative number with either a minus sign (-) or parentheses ().
Parametersvalue:String — Value to be formatted.
|
|
useSign:Boolean — If true , use a minus sign (-).
If false , use parentheses ().
|
String — Formatted number.
|
formatPrecision | () | method |
public function formatPrecision(value:String, precision:int):String
Formats a number by setting its decimal precision by using
the decimalSeparatorTo
property as the decimal separator.
value:String — Value to be formatted.
|
|
precision:int — Number of decimal points to use.
|
String — Formatted number.
|
formatRounding | () | method |
public function formatRounding(value:String, roundType:String):String
Formats a number by rounding it. The possible rounding types are defined by mx.formatters.NumberBaseRoundType.
Parametersvalue:String — Value to be rounded.
|
|
roundType:String — The type of rounding to perform:
NumberBaseRoundType.NONE, NumberBaseRoundType.UP,
NumberBaseRoundType.DOWN, or NumberBaseRoundType.NEAREST.
|
String — Formatted number.
|
See also
formatRoundingWithPrecision | () | method |
public function formatRoundingWithPrecision(value:String, roundType:String, precision:int):String
Formats a number by rounding it and setting the decimal precision. The possible rounding types are defined by mx.formatters.NumberBaseRoundType.
Parametersvalue:String — Value to be rounded.
|
|
roundType:String — The type of rounding to perform:
NumberBaseRoundType.NONE, NumberBaseRoundType.UP,
NumberBaseRoundType.DOWN, or NumberBaseRoundType.NEAREST.
|
|
precision:int — int of decimal places to use.
|
String — Formatted number.
|
See also
formatThousands | () | method |
public function formatThousands(value:String):String
Formats a number by using
the thousandsSeparatorTo
property as the thousands separator
and the decimalSeparatorTo
property as the decimal separator.
value:String — Value to be formatted.
|
String — Formatted number.
|
parseNumberString | () | method |
public function parseNumberString(str:String):String
Extracts a number from a formatted String. Examines the String from left to right and returns the first number sequence. Ignores thousands separators and includes the decimal and numbers trailing the decimal.
Parametersstr:String — String to parse for the numeric value.
|
String — Value, which can be a decimal.
|