RPA JS 扩展开发文档

RPA JS 扩展开发文档

  • SDK接口说明
  • 代码示例

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

ParameterTypeDescription
decimalPlacesnumber
roundingModeRoundingMode

Returns:

string

Last updated on 12/16/2020
  • BigNumber.toFixed() method
  • Parameters
Copyright © 2021 销售易