# 21.2 BigInt Objects

# 21.2.1 The BigInt Constructor

The BigInt

- is %BigInt%.
- is the initial value of the
"BigInt" property of theglobal object . - performs a type conversion when called as a function rather than as a
constructor . - is not intended to be used with the
`new`

operator or to be subclassed. It may be used as the value of an`extends`

clause of a class definition but a`super`

call to the BigIntconstructor will cause an exception.

# 21.2.1.1 BigInt ( `value` )

When `BigInt`

is called with argument `value`, the following steps are taken:

- If NewTarget is not
undefined , throw aTypeError exception. - Let
`prim`be ?ToPrimitive (`value`,number ). - If
Type (`prim`) is Number, return ?NumberToBigInt (`prim`). - Otherwise, return ?
ToBigInt (`value`).

# 21.2.1.1.1 NumberToBigInt ( `number` )

The abstract operation NumberToBigInt takes argument `number` (a Number). It performs the following steps when called:

- If
IsIntegralNumber (`number`) isfalse , throw aRangeError exception. - Return the BigInt value that represents
ℝ (`number`).

# 21.2.2 Properties of the BigInt Constructor

The value of the [[Prototype]] internal slot of the BigInt

The BigInt

# 21.2.2.1 BigInt.asIntN ( `bits`, `bigint` )

When the `BigInt.asIntN`

function is called with two arguments `bits` and `bigint`, the following steps are taken:

# 21.2.2.2 BigInt.asUintN ( `bits`, `bigint` )

When the `BigInt.asUintN`

function is called with two arguments `bits` and `bigint`, the following steps are taken:

# 21.2.2.3 BigInt.prototype

The initial value of `BigInt.prototype`

is the

This property has the attributes { [[Writable]]:

# 21.2.3 Properties of the BigInt Prototype Object

The BigInt prototype object:

- is %BigInt.prototype%.
- is an
ordinary object . - is not a BigInt object; it does not have a [[BigIntData]] internal slot.
- has a [[Prototype]] internal slot whose value is
%Object.prototype% .

The abstract operation thisBigIntValue takes argument `value`. It performs the following steps when called:

The phrase “this BigInt value” within the specification of a method refers to the result returned by calling the abstract operation

# 21.2.3.1 BigInt.prototype.constructor

The initial value of `BigInt.prototype.constructor`

is

# 21.2.3.2 BigInt.prototype.toLocaleString ( [ `reserved1` [ , `reserved2` ] ] )

An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement the `BigInt.prototype.toLocaleString`

method as specified in the ECMA-402 specification. If an ECMAScript implementation does not include the ECMA-402 API the following specification of the `toLocaleString`

method is used.

Produces a String value that represents this BigInt value formatted according to the conventions of the `toString`

.

The meanings of the optional parameters to this method are defined in the ECMA-402 specification; implementations that do not include ECMA-402 support must not use those parameter positions for anything else.

# 21.2.3.3 BigInt.prototype.toString ( [ `radix` ] )

The optional `radix` should be an _{𝔽} to _{𝔽}. If `radix` is _{𝔽} is used as the value of `radix`.

The following steps are performed:

- Let
`x`be ?thisBigIntValue (this value). - If
`radix`isundefined , let`radixMV`be 10. - Else, let
`radixMV`be ?ToIntegerOrInfinity (`radix`). - If
`radixMV`< 2 or`radixMV`> 36, throw aRangeError exception. - If
`radixMV`= 10, return !ToString (`x`). - Return the String representation of this
Number value using the radix specified by`radixMV`. Letters`a`

-`z`

are used for digits with values 10 through 35. The precise algorithm isimplementation-defined , however the algorithm should be a generalization of that specified in6.1.6.2.23 .

The `toString`

function is not generic; it throws a

# 21.2.3.4 BigInt.prototype.valueOf ( )

- Return ?
thisBigIntValue (this value).

# 21.2.3.5 BigInt.prototype [ @@toStringTag ]

The initial value of the

This property has the attributes { [[Writable]]: