Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

awesome64

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

awesome64 - npm Package Compare versions

Comparing version 1.0.0-alpha1 to 1.0.0-alpha2

14

index.js

@@ -38,12 +38,12 @@ 'use strict';

A64.prototype.iadd = function iadd(other) {
const selfLo = this.lo | 0;
const otherLo = other.lo | 0;
const selfLo = this.lo >>> 0;
const otherLo = other.lo >>> 0;
const selfHi = this.hi | 0;
const otherHi = other.hi | 0;
const lo = (selfLo + otherLo) | 0;
const carry = (lo < selfLo) | (lo < otherLo);
const sum = selfLo + otherLo;
const carry = (sum >= 0x100000000) | 0;
this.hi = ((selfHi + otherHi) | 0 + carry) | 0;
this.lo = lo | 0;
this.hi = (((selfHi + otherHi) | 0) + carry) | 0;
this.lo = sum | 0;

@@ -62,3 +62,3 @@ return this;

if (selfLo <0 && otherLo < 0)
if (selfLo < 0 && otherLo < 0)
carry = (carry + otherLo + selfLo) | 0;

@@ -65,0 +65,0 @@ else if (otherLo < 0)

{
"name": "awesome64",
"version": "1.0.0-alpha1",
"version": "1.0.0-alpha2",
"description": "Awesome Int64 num implementation",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -8,3 +8,3 @@ 'use strict';

function rnd32() {
return (Math.random() * 0x10000000) >>> 0;
return (Math.random() * 0x100000000) | 0;
}

@@ -35,2 +35,35 @@

it('should not fail on overflow regression', () => {
const a = new A64();
const b = new A64();
a.lo = 0x80000000 | 0;
b.lo = 0x80000000 | 0;
assert.equal(a.add(b).toString(), '0000000100000000');
});
it('should not fail on overflow regression#2', () => {
const a = new A64();
const b = new A64();
a.hi = -1401635801;
a.lo = 1372527499;
b.hi = 283000954;
b.lo = -987133892;
assert.equal(a.add(b).toString(), 'bd52fca216f8a3c7');
});
it('should not fail on overflow regression#3', () => {
const a = new A64();
const b = new A64();
a.hi = 427011201;
a.lo = -1128669244;
b.hi = 2117984826;
b.lo = 102420856;
assert.equal(a.add(b).toString(), '97b18ebbc2d4b13c');
});
it('should cross-check against BN', () => {

@@ -50,4 +83,9 @@ for (let i = 0; i < 1e5; i++) {

assert.equal(a.add(b).toString(),
an.add(bn).maskn(64).toString(16, 16));
try {
assert.equal(a.add(b).toString(),
an.add(bn).maskn(64).toString(16, 16));
} catch (e) {
console.error(a, b);
throw e;
}
}

@@ -54,0 +92,0 @@ });

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc