nodejs write 64bit unsigned integer to buffer

后端 未结 6 896
遥遥无期
遥遥无期 2021-02-14 03:08

I want to store a 64bit (8 byte) big integer to a nodejs buffer object in big endian format.

The problem about this task is that nodejs buffer only supports writing 32bi

6条回答
  •  耶瑟儿~
    2021-02-14 03:45

    // sending time
    var sending_time = new Date().getTime();
    buffer.writeInt32LE(parseInt(sending_time & 0xffffffff, 10), 16);
    buffer.writeInt32LE(parseInt(sending_time / 0xffffffff, 10), 20);
    

提交回复
热议问题