RPA JS 扩展开发文档

RPA JS 扩展开发文档

  • SDK接口说明
  • 代码示例

xsy-breeze-ui-rpa > BigNumber > random

BigNumber.random() method

Returns a new BigNumber with a pseudo-random value equal to or greater than 0 and less than 1.

The return value will have decimalPlaces decimal places, or less if trailing zeros are produced. If decimalPlaces is omitted, the current DECIMAL_PLACES setting will be used.

Depending on the value of this BigNumber constructor's CRYPTO setting and the support for the crypto object in the host environment, the random digits of the return value are generated by either Math.random (fastest), crypto.getRandomValues (Web Cryptography API in recent browsers) or crypto.randomBytes (Node.js).

To be able to set CRYPTO to true when using Node.js, the crypto object must be available globally:

global.crypto = require('crypto')

If CRYPTO is true, i.e. one of the crypto methods is to be used, the value of a returned BigNumber should be cryptographically secure and statistically indistinguishable from a random value.

Throws if decimalPlaces is invalid.

config({ DECIMAL_PLACES: 10 })
random()              // '0.4117936847'
random(20)            // '0.78193327636914089009'

Signature:

static random(decimalPlaces?: number): BigNumber;

Parameters

ParameterTypeDescription
decimalPlacesnumber

Returns:

BigNumber

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