Skip to content
Merged
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
118 changes: 118 additions & 0 deletions lib/node_modules/@stdlib/number/int64/base/assert/is-equal/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
<!--

@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.

-->

# isEqual

> Test whether two 64-bit signed integers are equal.

<!-- 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 isEqual = require( '@stdlib/number/int64/base/assert/is-equal' );
```

#### isEqual( a, b )

Tests whether two 64-bit signed integers are equal.

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

var a = new Int64( 1234 );
var b = Int64.of( 0, 1234 );

var out = isEqual( a, b );
// returns true
```

</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">

</section>

<!-- /.notes -->

<!-- Package usage examples. -->

<section class="examples">

## Examples

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

```javascript
var Int64 = require( '@stdlib/number/int64/ctor' );
var isEqual = require( '@stdlib/number/int64/base/assert/is-equal' );

var a = new Int64( 1234 );
var b = Int64.of( 0, 1234 );
var out = isEqual( a, b );
// returns true

a = new Int64( 1234 );
b = new Int64( 5678 );
out = isEqual( a, b );
// returns false
```

</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">

</section>

<!-- /.links -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* @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.
*/

'use strict';

// MODULES //

var bench = require( '@stdlib/bench' );
var MAX_SAFE_INTEGER = require( '@stdlib/constants/float64/max-safe-integer' );
var MIN_SAFE_INTEGER = require( '@stdlib/constants/float64/min-safe-integer' );
var Int64 = require( '@stdlib/number/int64/ctor' );
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive;
var pkg = require( './../package.json' ).name;
var isEqual = require( './../lib' );


// MAIN //

bench( pkg, function benchmark( b ) {
var x;
var y;
var i;
var v;

x = discreteUniform( 100, MIN_SAFE_INTEGER, MAX_SAFE_INTEGER );
y = [];
for ( i = 0; i < x.length; i++ ) {
y.push( new Int64( x[i] ) );
}

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
v = isEqual( y[ i % y.length ], y[ (i+1) % y.length ] );
if ( typeof v !== 'boolean' ) {
b.fail( 'should return a boolean' );
}
}
b.toc();
if ( !isBoolean( v ) ) {
b.fail( 'should return a boolean' );
}
b.pass( 'benchmark finished' );
b.end();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

{{alias}}( a, b )
Tests whether two 64-bit signed integers are equal.

Parameters
----------
a: Int64
First 64-bit signed integer.

b: Int64
Second 64-bit signed integer.

Returns
-------
out: boolean
Result.

Examples
--------
> var a = new {{alias:@stdlib/number/int64/ctor}}( 1234 );
> var b = {{alias:@stdlib/number/int64/ctor}}.of( 0, 1234 );
> var v = {{alias}}( a, b )
true

See Also
--------

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* @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.
*/

// TypeScript Version: 4.1

/// <reference types="@stdlib/types"/>

import { Int64 } from '@stdlib/types/number';

/**
* Tests whether two 64-bit signed integers are equal.
*
* @param a - first 64-bit signed integer
* @param b - second 64-bit signed integer
* @returns boolean indicating if both 64-bit signed integers are equal
*
* @example
* var Int64 = require( '@stdlib/number/int64/ctor' );
*
* var a = new Int64( 1234 );
* var b = Int64.of( 0, 1234 );
*
* var v = isEqual( a, b );
* // returns true
*/
declare function isEqual( a: Int64, b: Int64 ): boolean;


// EXPORTS //

export = isEqual;
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* @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.
*/

import Int64 = require( '@stdlib/number/int64/ctor' );
import isEqual = require( './index' );


// TESTS //

// The function returns a boolean...
{
const a = new Int64( 1234 );
const b = Int64.of( 0, 1234 );

isEqual( a, b ); // $ExpectType boolean
}

// The compiler throws an error if the function is provided a first argument which is not a 64-bit signed integer...
{
const b = new Int64( 1234 );

isEqual( 'abc', b ); // $ExpectError
isEqual( 123, b ); // $ExpectError
isEqual( true, b ); // $ExpectError
isEqual( false, b ); // $ExpectError
isEqual( [], b ); // $ExpectError
isEqual( {}, b ); // $ExpectError
isEqual( ( x: number ): number => x, b ); // $ExpectError
}

// The compiler throws an error if the function is provided a second argument which is not a 64-bit signed integer...
{
const a = new Int64( 1234 );

isEqual( a, 'abc' ); // $ExpectError
isEqual( a, 123 ); // $ExpectError
isEqual( a, true ); // $ExpectError
isEqual( a, false ); // $ExpectError
isEqual( a, [] ); // $ExpectError
isEqual( a, {} ); // $ExpectError
isEqual( a, ( x: number ): number => x ); // $ExpectError
}

// The compiler throws an error if the function is provided an unsupported number of arguments...
{
const a = new Int64( 1234 );
const b = Int64.of( 0, 1234 );

isEqual(); // $ExpectError
isEqual( a ); // $ExpectError
isEqual( a, b, {} ); // $ExpectError
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* @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.
*/

'use strict';

var Int64 = require( '@stdlib/number/int64/ctor' );
var isEqual = require( './../lib' );

var a = new Int64( 1234 );
var b = Int64.of( 0, 1234 );
var out = isEqual( a, b );
console.log( out );
// => true

a = new Int64( 1234 );
b = new Int64( 5678 );
out = isEqual( a, b );
console.log( out );
// => false
Loading