I collected funcs searching for conversion from integer to binary with different sizes, and re-visiting the code I'm thinking maybe what I recorded as 64 bit integer was actually signed 32 bit?
const readInt64 = (b) => {
return parseInt(b.toString('hex'), 16)
}
const setInt64 = (int64) => {
const b = Buffer.alloc(8);
const MAX_UINT32 = 0xFFFFFFFF;
const big = ~~(int64 / MAX_UINT32);
const low = (int64 % MAX_UINT32) - big;
b.writeUInt32BE(big, 0); // 00 00 01 53 00 00 00 00
b.writeUInt32BE(low, 4); // 00 00 01 53 36 9a 06 58
return b;
}
Which is it? I'm confused because if I understand right, Node.js doesn't support 64 bit integers. Or at least not absolutely.