BigInt

A JavaScript BigInt value.

Methods

New

cpp static Napi::BigInt Napi::BigInt::New(Napi::Env env, int64_t value);

These APIs convert the C int64_t and uint64_t types to the JavaScript BigInt type.

cpp static Napi::BigInt Napi::BigInt::New(Napi::Env env, int sign_bit, size_t word_count, const uint64_t* words);

This API converts an array of unsigned 64-bit words into a single BigInt value.

The resulting BigInt is calculated as: (–1)sign_bit (words[0] × (264)0 + words[1] × (264)1 + …)

Returns a new JavaScript BigInt.

Constructor

cpp Napi::BigInt();

Returns a new empty JavaScript Napi::BigInt.

Int64Value

cpp int64_t Napi::BitInt::Int64Value(bool* lossless) const;

Returns the C int64_t primitive equivalent of the given JavaScript BigInt. If needed it will truncate the value, setting lossless to false.

Uint64Value

cpp uint64_t Napi::BigInt::Uint64Value(bool* lossless) const;

Returns the C uint64_t primitive equivalent of the given JavaScript BigInt. If needed it will truncate the value, setting lossless to false.

WordCount

cpp size_t Napi::BigInt::WordCount() const;

Returns the number of words needed to store this BigInt value.

ToWords

cpp void Napi::BigInt::ToWords(size_t* word_count, int* sign_bit, uint64_t* words);

Returns a single BigInt value into a sign bit, 64-bit little-endian array, and the number of elements in the array.