Skip to content

stdlib-js/number-uint64-ctor

About stdlib...

We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.

The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.

When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.

To join us in bringing numerical computing to the web, get started by checking us out on GitHub, and please consider financially supporting stdlib. We greatly appreciate your continued support!

Uint64

NPM version Build Status Coverage Status

Unsigned 64-bit integer.

Installation

npm install @stdlib/number-uint64-ctor

Alternatively,

  • To load the package in a website via a script tag without installation and bundlers, use the ES Module available on the esm branch (see README).
  • If you are using Deno, visit the deno branch (see README for usage intructions).
  • For use in Observable, or in browser/node environments, use the Universal Module Definition (UMD) build available on the umd branch (see README).

The branches.md file summarizes the available branches and displays a diagram illustrating their relationships.

To view installation and usage instructions specific to each branch build, be sure to explicitly navigate to the respective README files on each branch, as linked to above.

Usage

var Uint64 = require( '@stdlib/number-uint64-ctor' );

Uint64( value )

Unsigned 64-bit integer constructor.

var x = new Uint64( 5 );
// returns <Uint64>

Properties

Uint64.name

Static property returning the constructor name.

var str = Uint64.name;
// returns 'Uint64'

Uint64.BYTES_PER_ELEMENT

Size (in bytes) of the underlying value.

var nbytes = Uint64.BYTES_PER_ELEMENT;
// returns 8

Uint64.prototype.BYTES_PER_ELEMENT

Size (in bytes) of the underlying value.

var x = new Uint64( 5 );

var nbytes = x.BYTES_PER_ELEMENT;
// returns 8

Uint64.prototype.byteLength

Size (in bytes) of the underlying value.

var x = new Uint64( 5 );

var nbytes = x.byteLength;
// returns 8

Uint64.prototype.hi

High 32-bit word of an unsigned 64-bit integer.

var x = Uint64.from( [ 1234, 5678 ] );

var w = x.hi;
// returns 1234

Uint64.prototype.lo

Low 32-bit word of an unsigned 64-bit integer.

var x = Uint64.from( [ 1234, 5678 ] );

var w = x.lo;
// returns 5678

Methods

Static Methods

Uint64.from( array )

Creates a new unsigned 64-bit integer from an array-like object containing a high and low word.

var x = Uint64.from( [ 1234, 5678 ] );
// returns <Uint64>

Uint64.of( high, low )

Creates a new unsigned 64-bit integer from a high and low word.

var x = Uint64.of( 1234, 5678 );
// returns <Uint64>

Accessor Methods

These methods do not mutate a Uint64 instance and, instead, return an unsigned 64-bit integer representation.

Uint64.prototype.toString()

Returns a string representation of a Uint64 instance.

var x = new Uint64( 5 );
var str = x.toString();
// returns '5'

Uint64.prototype.toJSON()

Returns a JSON representation of a Uint64 instance. JSON.stringify() implicitly calls this method when stringifying a Uint64 instance.

var x = new Uint64( 5 );

var o = x.toJSON();
// returns { 'type': 'Uint64', 'words': [ 0, 5 ] }

To revive a Uint64 instance from a JSON string, see @stdlib/number/uint64/reviver.

Uint64.prototype.valueOf()

Converts a Uint64 instance to a primitive value.

var x = new Uint64( 5 );

var v = x.valueOf();
// e.g., returns <bigint>

Notes

  • An unsigned 64-bit integer has a range of [0, 2^64-1].

Examples

var Uint64 = require( '@stdlib/number-uint64-ctor' );

var x = new Uint64( 1234 );

console.log( 'type: %s', typeof x );
// => 'type: object'

console.log( 'str: %s', x );
// => 'str: 1234'

console.log( 'JSON: %s', JSON.stringify( x ) );
// => 'JSON: {"type":"Uint64","words":[0,1234]}'

Notice

This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.

For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.

Community

Chat


License

See LICENSE.

Copyright

Copyright © 2016-2026. The Stdlib Authors.