node函数buf.readDoubleBE详解

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/w178191520/article/details/79101445

buf.readDoubleBE(offset[, noAssert])

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

从该 Buffer 指定的带有特定尾数格式(readDoubleBE() 返回一个较大的尾数,readDoubleLE() 返回一个较小的尾数)的 offset 位置开始读取一个64位双精度值。

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

const buf = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]);

buf.readDoubleBE();
// Returns: 8.20788039913184e-304
buf.readDoubleLE();
// Returns: 5.447603722011605e-270
buf.readDoubleLE(1);
// throws RangeError: Index out of range

buf.readDoubleLE(1, true); // Warning: reads passed end of buffer!
// Segmentation fault! don't do this!

猜你喜欢

转载自blog.csdn.net/w178191520/article/details/79101445
今日推荐