Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong cmpn result #294

Open
devDesu opened this issue May 3, 2022 · 1 comment
Open

Wrong cmpn result #294

devDesu opened this issue May 3, 2022 · 1 comment

Comments

@devDesu
Copy link

devDesu commented May 3, 2022

Version: 5.2.0
Node version: v17.5.0

let x = new BN(9000000000);
assert.equal(x.gten(100000000000), false); // error!

I've checked cmpn function and it seems that it's the source of the problem because x.cmpn(100000000000) returns 1 which means that A (9000000000) > B (100000000000)

This works fine

let x = new BN(9000000000);
assert.equal(x.gte(new BN(100000000000)), false); // ok
@fanatid
Copy link
Collaborator

fanatid commented May 3, 2022

Thanks. Probably we need to move this assertion before if.

bn.js/lib/bn.js

Line 2854 in db57519

assert(num <= 0x3ffffff, 'Number is too big');

Currently, I'd recommend using BigInt instead of bn.js.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants