I have a simple bitshift operation in c# that I am porting to JS. You can see it here: https://dotnetfiddle.net/Au62NB
//C# code
ulong v = 2630423132685782527;
UInt32 v1 = (UInt32)(v >> 32);
UInt32 v0 = (UInt32)((v << 32) >> 32);
Console.WriteLine("v1:v0 " + v1 +" : " + v0); //v1:v0 612443111 : 280284671
Value v0 is always off by 1 in NodeJS (280284672
). I have tried everything I could find on google, BigInt, big-integer library from npm, etc. Does anyone have an idea?
let v = BigInt('2630423132685782527');
let v1 = v >> BigInt(32)
let v0 = (v << BigInt(32)) >> BigInt(32);
v0 = Number(v0) >>> 0; //not even sure why I have to do this, something with converting signed/unsigned.
console.log("v1:v0", Number(v1), Number(v0)); //"v1:v0", 612443111, 280284672