Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
273 changes: 273 additions & 0 deletions lib/node_modules/@stdlib/number/int64/ctor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,273 @@
<!--

@license Apache-2.0

Copyright (c) 2026 The Stdlib Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

-->

# Int64

> 64-bit signed integer.

<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->

<section class="intro">

</section>

<!-- /.intro -->

<!-- Package usage documentation. -->

<section class="usage">

## Usage

```javascript
var Int64 = require( '@stdlib/number/int64/ctor' );
```

#### Int64( value )

64-bit signed integer constructor.

```javascript
var x = new Int64( 5 );
// returns <Int64>
```

* * *

## Properties

#### Int64.name

Static property returning the constructor name.

```javascript
var str = Int64.name;
// returns 'Int64'
```

#### Int64.BYTES_PER_ELEMENT

Size (in bytes) of the underlying value.

```javascript
var nbytes = Int64.BYTES_PER_ELEMENT;
// returns 8
```

#### Int64.prototype.BYTES_PER_ELEMENT

Size (in bytes) of the underlying value.

```javascript
var x = new Int64( 5 );

var nbytes = x.BYTES_PER_ELEMENT;
// returns 8
```

#### Int64.prototype.byteLength

Size (in bytes) of the underlying value.

```javascript
var x = new Int64( 5 );

var nbytes = x.byteLength;
// returns 8
```

#### Int64.prototype.hi

High 32-bit word of a 64-bit signed integer.

```javascript
var x = Int64.from( [ 1234, 5678 ] );

var w = x.hi;
// returns 1234
```

#### Int64.prototype.lo

Low 32-bit word of a 64-bit signed integer.

```javascript
var x = Int64.from( [ 1234, 5678 ] );

var w = x.lo;
// returns 5678
```

* * *

## Methods

### Static Methods

#### Int64.from( array )

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

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

#### Int64.of( high, low )

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

```javascript
var x = Int64.of( 1234, 5678 );
// returns <Int64>
```

### Accessor Methods

These methods do **not** mutate a `Int64` instance and, instead, return a 64-bit signed integer representation.

#### Int64.prototype.toString()

Returns a string representation of a `Int64` instance.

```javascript
var x = new Int64( 5 );
var str = x.toString();
// returns '5'
```

#### Int64.prototype.toJSON()

Returns a [JSON][json] representation of a `Int64` instance. [`JSON.stringify()`][mdn-json-stringify] implicitly calls this method when stringifying a `Int64` instance.

```javascript
var x = new Int64( 5 );

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

To [revive][mdn-json-parse] a `Int64` instance from a [JSON][json] string, see [@stdlib/number/int64/reviver][@stdlib/number/int64/reviver].

#### Int64.prototype.valueOf()

Converts a `Int64` instance to a primitive value.

```javascript
var x = new Int64( 5 );

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

</section>

<!-- /.usage -->

* * *

<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="notes">

## Notes

- A 64-bit signed integer has a range of \[`-(2^63)`, `2^63-1`\].

</section>

<!-- /.notes -->

* * *

<!-- Package usage examples. -->

<section class="examples">

## Examples

<!-- eslint no-undef: "error" -->

```javascript
var Int64 = require( '@stdlib/number/int64/ctor' );

var x = new Int64( 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":"Int64","words":[0,1234]}'

x = new Int64( -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":"Int64","words":[4294967295,4294966062]}'
```

</section>

<!-- /.examples -->


<!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="references">

</section>

<!-- /.references -->

<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->

<section class="related">

</section>

<!-- /.related -->

<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="links">

[json]: http://www.json.org/

[mdn-json-stringify]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify

[mdn-json-parse]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse

[@stdlib/number/int64/reviver]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/number/int64/reviver

<!-- <related-links> -->

<!-- </related-links> -->

</section>

<!-- /.links -->
Loading