TooTallNate / ref

Turn Buffer instances into "pointers"
http://tootallnate.github.com/ref
453 stars 141 forks source link

Using Long Long #25

Closed harrisonhjones closed 9 years ago

harrisonhjones commented 9 years ago

I've successfully user ref to grab a long long type from a call to user32. I can't, for the life of me, get it to "split" it into two longs. If i try to right shift >> by 32 it simply returns 0 or (even stranger) returns the first 32 bits. Suggestions? If I output the number using .deref() I get the correct result however I can't shift it down by 32 bits to grab the second long.

harrisonhjones commented 9 years ago

Note. I was able to solve this using the following method:

First, use node-int64 to capture the longlong:

var num = new Int64(outNumber.deref());

Then get rid of the top 32 bits:

var num1 = num & 0xFFFFFFFF;

Then get rid of the bottom 32 bits:

var num2 = (num-num1)/4294967296;