RPA JS 扩展开发文档

RPA JS 扩展开发文档

  • SDK接口说明
  • 代码示例

xsy-breeze-ui-rpa > BigNumber > toPrecision

BigNumber.toPrecision() method

Returns a string representing the value of this BigNumber rounded to significantDigits significant digits using rounding mode roundingMode.

If significantDigits is less than the number of digits necessary to represent the integer part of the value in normal (fixed-point) notation, then exponential notation is used.

If significantDigits is omitted, or is null or undefined, then the return value is the same as n.toString().

If roundingMode is omitted or is null or undefined, ROUNDING_MODE is used.

Throws if significantDigits or roundingMode is invalid.

x = 45.6
y = new BigNumber(x)
x.toPrecision()                 // '45.6'
y.toPrecision()                 // '45.6'
x.toPrecision(1)                // '5e+1'
y.toPrecision(1)                // '5e+1'
y.toPrecision(2, 0)             // '4.6e+1'  (ROUND_UP)
y.toPrecision(2, 1)             // '4.5e+1'  (ROUND_DOWN)
x.toPrecision(5)                // '45.600'
y.toPrecision(5)                // '45.600'

Signature:

toPrecision(significantDigits: number, roundingMode?: RoundingMode): string;

Parameters

ParameterTypeDescription
significantDigitsnumber
roundingModeRoundingMode

Returns:

string

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