The NumberBase class is a utility class that contains general number formatting capabilities, including rounding, precision, thousands formatting, and negative sign formatting. The implementation of the formatter classes use this class.
See also:
Constructor
new(decimalSeparatorFrom:String = ".", thousandsSeparatorFrom:String = ",", decimalSeparatorTo:String = ".", thousandsSeparatorTo:String = ",")
Constructor.
Parameters:
decimalSeparatorFrom | Decimal separator to use when parsing an input String. |
---|---|
thousandsSeparatorFrom | Character to use as the thousands separator in the input String. |
decimalSeparatorTo | Decimal separator character to use when outputting formatted decimal numbers. |
thousandsSeparatorTo | Character to use as the thousands separator in the output String. |
Variables
decimalSeparatorTo:String
Decimal separator character to use when outputting formatted decimal numbers.
Methods
expandExponents(value:String):String
Formats a number in exponent notation, into a number in decimal notation.
Parameters:
str | String to process in exponent notation. |
---|
Returns:
Formatted number.
formatDecimal(value:String):String
Formats a number by replacing the default decimal separator, ".",
with the decimal separator specified by decimalSeparatorTo
.
Parameters:
value | The String value of the Number (formatted American style ####.##). |
---|
Returns:
String representation of the input where "." is replaced with the decimal formatting character.
formatNegative(value:String, useSign:Bool):String
Formats a negative number with either a minus sign (-) or parentheses ().
Parameters:
value | Value to be formatted. |
---|---|
useSign | If |
Returns:
Formatted number.
formatPrecision(value:String, precision:Int):String
Formats a number by setting its decimal precision by using
the decimalSeparatorTo
property as the decimal separator.
Parameters:
value | Value to be formatted. |
---|---|
precision | Number of decimal points to use. |
Returns:
Formatted number.
formatRounding(value:String, roundType:String):String
Formats a number by rounding it. The possible rounding types are defined by feathers.formatters.NumberBaseRoundType.
Parameters:
value | Value to be rounded. |
---|---|
roundType | The type of rounding to perform: NumberBaseRoundType.NONE, NumberBaseRoundType.UP, NumberBaseRoundType.DOWN, or NumberBaseRoundType.NEAREST. |
Returns:
Formatted number.
See also:
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 feathers.formatters.NumberBaseRoundType.
Parameters:
value | Value to be rounded. |
---|---|
roundType | The type of rounding to perform: NumberBaseRoundType.NONE, NumberBaseRoundType.UP, NumberBaseRoundType.DOWN, or NumberBaseRoundType.NEAREST. |
precision | int of decimal places to use. |
Returns:
Formatted number.
See also:
formatThousands(value:String):String
Formats a number by using
the thousandsSeparatorTo
property as the thousands separator
and the decimalSeparatorTo
property as the decimal separator.
Parameters:
value | Value to be formatted. |
---|
Returns:
Formatted number.
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.
Parameters:
str | String to parse for the numeric value. |
---|
Returns:
Value, which can be a decimal.