GoogleChromeLabs / jsbi

JSBI is a pure-JavaScript implementation of the official ECMAScript BigInt proposal.
https://v8.dev/features/bigint#polyfilling-transpiling
Apache License 2.0
919 stars 68 forks source link

asIntN appears to give wrong value #66

Closed aflin closed 3 years ago

aflin commented 3 years ago
var JSBI =require('jsbi');

a = JSBI.BigInt('-2562362345234747635679540932095783458054366');

b=JSBI.asUintN(20, a);
c=JSBI.asIntN(20, a);

console.log(b.toString());
console.log(c.toString());

/* output:

   515874
   515874

*/

Or maybe I don't understand how it is supposed to work.

aflin commented 3 years ago

Sorry. Apparently I don't know how it works.