1 Properties of the BigInt Constructor
The BigInt constructor:
- has a [[Prototype]] internal slot whose value is %Function.prototype%.
- has the following properties:
1.1 BigInt.abs ( x )
This function returns the absolute value of x as a BigInt; the result has the same magnitude as x but has positive sign.
It performs the following steps when called:
- Let n be ? ToBigInt(x).
- Return the BigInt value that represents abs(ℝ(x)).
1.2 BigInt.asIntN ( bits, bigint )
This function performs the following steps when called:
- Set bits to ? ToIndex(bits).
- Set bigint to ? ToBigInt(bigint).
- Let mod be ℝ(bigint) modulo 2bits.
- If mod ≥ 2bits - 1, return ℤ(mod - 2bits); otherwise, return ℤ(mod).
1.3 BigInt.asUintN ( bits, bigint )
This function performs the following steps when called:
- Set bits to ? ToIndex(bits).
- Set bigint to ? ToBigInt(bigint).
- Return ℤ(ℝ(bigint) modulo 2bits).
1.4 BigInt.cbrt ( x )
This function returns the cube root of x as a BigInt.
It performs the following steps when called:
- Let n be ? ToBigInt(x).
- Let root be the cube root of ℝ(n).
- Return ℤ(truncate(root)).
1.5 BigInt.max ( firstArg, ...restArgs )
Given one or more arguments, this function calls ToBigInt on each of the arguments and returns the largest of the resulting values.
It performs the following steps when called:
- Let firstCoerced be ? ToBigInt(firstArg).
- Let restCoerced be a new empty List.
- For each element arg of restArgs, do
- Let n be ? ToBigInt(arg).
- Append n to restCoerced.
- Let highest be firstCoerced.
- For each element number of restCoerced, do
- If number > highest, set highest to number.
- Return highest.
The "length" property of this function is 2𝔽.
1.6 BigInt.min ( firstArg, ...restArgs )
Given one or more arguments, this function calls ToBigInt on each of the arguments and returns the smallest of the resulting values.
It performs the following steps when called:
- Let firstCoerced be ? ToBigInt(firstArg).
- Let restCoerced be a new empty List.
- For each element arg of restArgs, do
- Let n be ? ToBigInt(arg).
- Append n to restCoerced.
- Let lowest be firstCoerced.
- For each element number of restCoerced, do
- If number < lowest, set lowest to number.
- Return lowest.
The "length" property of this function is 2𝔽.
1.7 BigInt.pow ( base, exponent )
This function performs the following steps when called:
- Set base to ? ToBigInt(base).
- Set exponent to ? ToBigInt(exponent).
- Return Number::exponentiate(base, exponent).
1.8 BigInt.prototype
The initial value of BigInt.prototype
is the BigInt prototype object.
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
1.9 BigInt.sign ( x )
This function returns the sign of x as a BigInt, indicating whether x is positive, negative, or zero.
It performs the following steps when called:
- Let n be ? ToBigInt(x).
- If n is 0ℤ, return n.
- If n < 0ℤ, return -1ℤ.
- Return 1ℤ.
1.10 BigInt.sqrt ( x )
This function returns the square root of x as a BigInt.
It performs the following steps when called:
- Let n be ? ToBigInt(x).
- If n < 0ℤ, throw a RangeError exception.
- Let root be the square root of ℝ(n).
- Return ℤ(truncate(root)).