xsy-breeze-ui-rpa > BigNumber > toFixed
BigNumber.toFixed() method
Returns a string representing the value of this BigNumber in normal (fixed-point) notation rounded to decimalPlaces decimal places using rounding mode roundingMode.
If the value of this BigNumber in normal notation has fewer than decimalPlaces fraction digits, the return value will be appended with zeros accordingly.
Unlike Number.prototype.toFixed, which returns exponential notation if a number is greater or equal to 10**21, this method will always return normal notation.
If decimalPlaces is omitted or is null or undefined, the return value will be unrounded and in normal notation. This is also unlike Number.prototype.toFixed, which returns the value to zero decimal places. It is useful when normal notation is required and the current EXPONENTIAL_AT setting causes toString to return exponential notation.
If roundingMode is omitted or is null or undefined, ROUNDING_MODE is used.
Throws if decimalPlaces or roundingMode is invalid.
x = 3.456
y = new BigNumber(x)
x.toFixed() // '3'
y.toFixed() // '3.456'
y.toFixed(0) // '3'
x.toFixed(2) // '3.46'
y.toFixed(2) // '3.46'
y.toFixed(2, 1) // '3.45' (ROUND_DOWN)
x.toFixed(5) // '3.45600'
y.toFixed(5) // '3.45600'
Signature:
toFixed(decimalPlaces: number, roundingMode?: RoundingMode): string;
Parameters
| Parameter | Type | Description |
|---|---|---|
| decimalPlaces | number | |
| roundingMode | RoundingMode |
Returns:
string
