您现在的位置:首页 >> 前端 >> 内容

buf.readInt16LE函数详解

时间:2018/1/19 15:16:48 点击:

  核心提示:buf.readInt16BE(offset[, noAssert])offset {Number} 0 = offset = buf.length - 2 noAssert {Boolean} 默认...

buf.readInt16BE(offset[, noAssert])

offset {Number} 0 <= offset <= buf.length - 2 noAssert {Boolean} 默认:false 返回:{Number}

从该 Buffer 指定的带有特定尾数格式(readInt16BE() 返回一个较大的尾数,readInt16LE() 返回一个较小的尾数)的 offset 位置开始读取一个16位整数值。

设置 noAssert 为 true ,将跳过对 offset 的验证。这将允许 offset 超出缓冲区的末尾。

从 Buffer 里读取的整数数值会被解释执行为有符号的2的补码值。

const buf = Buffer.from([1, -2, 3, 4]);

buf.readInt16BE();
// returns 510
buf.readInt16LE(1);
// returns 1022

Tags:BU UF FR RE 
作者:网络 来源:hellogril前