buf.writeInt16BE(value, offset[, noAssert])

buf.writeInt16LE(value, offset[, noAssert])

  • value {Number} 需要被写入到 Buffer 的字节
  • offset {Number} 0
  • noAssert {Boolean} 默认:false
  • 返回:{Number} 偏移加上被写入的字节数

从该 Buffer 指定的带有特定尾数格式(writeInt16BE() 写入一个较大的尾数,writeInt16LE() 写入一个较小的尾数)的 offset 位置开始写入 value 。value 参数应当是一个有效的有符号的16位整数。当值不是一个有符号的16位整数时,它的行为是不确定的。
将 noAssert 设为 true 将跳过对 value 和 offset 的验证。这意味着 value 可能对于这个特定的函数来说过大,并且 offset 可能超出该 Buffer 的末端,导致该值被直接丢弃。除非确定你的内容的正确性否则不应该被使用。
这个 value 作为一个2的补码的有符号的整数被解释执行和写入。
```
const buf = Buffer.allocUnsafe(4);
buf.writeInt16BE(0x0102, 0);
buf.writeInt16LE(0x0304, 2);
console.log(buf);
// Prints:
```

buf.writeInt16BE()函数详解的更多相关文章

  1. buf.writeUInt8()函数详解

    buf.writeUInt8(value, offset[, noAssert]) value {Number} 需要被写入到 Buffer 的字节 offset {Number} 0 <= o ...

  2. buf.writeUIntBE()函数详解

    buf.writeUIntBE(value, offset, byteLength[, noAssert]) buf.writeUIntLE(value, offset, byteLength[, n ...

  3. buf.writeInt32BE()函数详解

    buf.writeInt32BE(value, offset[, noAssert]) buf.writeInt32LE(value, offset[, noAssert]) value {Numbe ...

  4. buf.writeInt8()函数详解

    buf.writeInt8(value, offset[, noAssert]) value {Number} 需要被写入到 Buffer 的字节 offset {Number} 0 <= of ...

  5. buf.writeDoubleBE()函数详解

    buf.writeDoubleBE(value, offset[, noAssert]) buf.writeDoubleLE(value, offset[, noAssert]) value {Num ...

  6. buf.writeFloatBE()函数详解

    buf.writeFloatBE(value, offset[, noAssert]) buf.writeFloatLE(value, offset[, noAssert]) value {Numbe ...

  7. buf.writeIntBE()函数详解

    buf.writeIntBE(value, offset, byteLength[, noAssert]) buf.writeIntLE(value, offset, byteLength[, noA ...

  8. buf.readUInt32BE()函数详解

    buf.readUInt32BE(offset[, noAssert]) buf.readUInt32LE(offset[, noAssert]) offset {Number} 0 noAssert ...

  9. buf.readInt32LE函数详解

    offset {Number} 0 noAssert {Boolean} 默认:false 返回:{Number} 从该 Buffer 指定的带有特定尾数格式(readInt32BE() 返回一个较大 ...

随机推荐

  1. BS与CS的联系与区别。

    C/S是Client/Server的缩写.服务器通常采用高性能的PC.工作站或小型机,并采用大型数据库系统,如Oracle.Sybase.Informix或 SQL Server.客户端需要安装专用的 ...

  2. [Codeforces 449B] Jzzhu and Cities

    [题目链接] https://codeforces.com/contest/449/problem/B [算法] 最短路 时间复杂度 : O(N ^ 2) [代码] #include<bits/ ...

  3. [bzoj3073]Journeys

    https://www.zybuluo.com/ysner/note/1295471 题面 \(Seter\)建造了一个很大的星球,他准备建造\(N\)个国家和无数双向道路.\(N\)个国家很快建造好 ...

  4. 20. Extjs学习笔记——Ext.data.JsonStore使用说明

    Ext.data.JsonStore继承于Ext.data.Store,使得从远程JSON数据创建stores更为方便的简单辅助类.JsonStore合成了Ext.data.HttpProxy与Ext ...

  5. C 的数据类型和基本类型转换方式

    C中的类型分为 整数数据类型 浮点类型 void类型 基本类型符号: 默认数值为十进制,例如:10,20 以0开头的数值为八进制,例如:010,020 以0b开头的数值为二进制,例如:0b0011 以 ...

  6. Eclipse使用Tomcat发布项目时出现YadisException异常解决方案

    调整使用Eclipse的JDK版本,大概JDK版本过低会出现这个org.openid4java.discovery.yadis.YadisException: 0x704: I/O transport ...

  7. js获取标签的三种方式

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  8. Troubleshooting Guide for ORA-12541 TNS: No Listener

    Server side checks (not platform specific): 1)  Check the result on the server using tnsping to the ...

  9. 299 Bulls and Cows 猜数字游戏

    你正在和你的朋友玩猜数字(Bulls and Cows)游戏:你写下一个数字让你的朋友猜.每次他猜测后,你给他一个提示,告诉他有多少位数字和确切位置都猜对了(称为”Bulls“, 公牛),有多少位数字 ...

  10. D. Fedor and coupons 二分暴力

    http://codeforces.com/contest/754/problem/D 给出n条线段,选出k条,使得他们的公共部分长度最大. 公共部分的长度,可以二分出来,为val.那么怎么判断有k条 ...