buf.writeFloatBE()函数详解
buf.writeFloatBE(value, offset[, noAssert])
buf.writeFloatLE(value, offset[, noAssert])
- value {Number} 需要被写入到 Buffer 的字节
- offset {Number} 0
- noAssert {Boolean} 默认:false
- 返回:{Number} 偏移加上被写入的字节数
从该 Buffer 指定的带有特定尾数格式(writeFloatBE() 写入一个较大的尾数,writeFloatLE() 写入一个较小的尾数)的 offset 位置开始写入 value 。当值不是一个32位浮点值时,它的行为是不确定的。
将 noAssert 设为 true 将跳过对 value 和 offset 的验证。这意味着 value 可能对于这个特定的函数来说过大,并且 offset 可能超出该 Buffer 的末端,导致该值被直接丢弃。除非确定你的内容的正确性否则不应该被使用。
例子:
```
const buf = Buffer.allocUnsafe(4);
buf.writeFloatBE(0xcafebabe, 0);
console.log(buf);
// Prints: <Buffer 4f 4a fe bb>
buf.writeFloatLE(0xcafebabe, 0);
console.log(buf);
// Prints: <Buffer bb fe 4a 4f>
buf.writeFloatBE()函数详解的更多相关文章
- buf.writeUInt8()函数详解
buf.writeUInt8(value, offset[, noAssert]) value {Number} 需要被写入到 Buffer 的字节 offset {Number} 0 <= o ...
- buf.writeUIntBE()函数详解
buf.writeUIntBE(value, offset, byteLength[, noAssert]) buf.writeUIntLE(value, offset, byteLength[, n ...
- buf.writeInt32BE()函数详解
buf.writeInt32BE(value, offset[, noAssert]) buf.writeInt32LE(value, offset[, noAssert]) value {Numbe ...
- buf.writeInt16BE()函数详解
buf.writeInt16BE(value, offset[, noAssert]) buf.writeInt16LE(value, offset[, noAssert]) value {Numbe ...
- buf.writeInt8()函数详解
buf.writeInt8(value, offset[, noAssert]) value {Number} 需要被写入到 Buffer 的字节 offset {Number} 0 <= of ...
- buf.writeDoubleBE()函数详解
buf.writeDoubleBE(value, offset[, noAssert]) buf.writeDoubleLE(value, offset[, noAssert]) value {Num ...
- buf.writeIntBE()函数详解
buf.writeIntBE(value, offset, byteLength[, noAssert]) buf.writeIntLE(value, offset, byteLength[, noA ...
- buf.readUInt32BE()函数详解
buf.readUInt32BE(offset[, noAssert]) buf.readUInt32LE(offset[, noAssert]) offset {Number} 0 noAssert ...
- buf.readInt32LE函数详解
offset {Number} 0 noAssert {Boolean} 默认:false 返回:{Number} 从该 Buffer 指定的带有特定尾数格式(readInt32BE() 返回一个较大 ...
随机推荐
- T3 最短路 line
T3 最短路 line [问题描述] 给定一个 n 个点,m 条边的有向图,每个点有一个权值 a[i],表示这个点要到达多少次,1 为起始点,从 1 到 i 的距离为 d[i],请你输出∑a[i]*d ...
- python-----查看显卡gpu信息
需要安装pynvml库. 下载地址为:https://pypi.org/project/nvidia-ml-py/#history pip安装的命令为: pip install nvidia-ml-p ...
- UVaLive 6833 Miscalculation (表达式计算)
题意:给定一个表达式,只有+*,然后问你按照法则运算和从左到右计算结果有什么不同. 析:没什么可说的,直接算两次就好. 代码如下: #pragma comment(linker, "/STA ...
- bzoj 1599: [Usaco2008 Oct]笨重的石子【枚举】
--我为什么要写这种题解-- 枚举投掷情况即可 #include<iostream> #include<cstdio> using namespace std; int s1, ...
- c++ strcmp函数
用法:加头文件 #include <string.h> 功能:比较字符串s1和s2. 一般形式:strcmp(字符串1,字符串2) 返回值: 当s1<s2时,返回值<0 当s1 ...
- MySQL与Sqlserver数据获取
由于项目要求,一个.net mvc登录注册的东西网站必须放弃sqlserver数据去使用MySQL数据库,因此我遇到了一些问题,并找出相应的解决方法, 因为sqlserver跟MySQL的数据引擎不同 ...
- Spring.Net学习笔记(6)-方法注入
一.开发环境 系统:win10 编译器:VS2013 二.涉及程序集 Spring.Core.dll 1.3.1 Common.Logging.dll 三.开发过程 1.项目结构 2.编写Mobile ...
- 微信小程序授权 获取用户的openid和session_key【后端使用java语言编写】,我写的是get方式,目的是测试能否获取到微信服务器中的数据,后期我会写上post请求方式。
在这里给大家分享下我的心得,1.写代码前一定要对整个流程有个了解.我就是因为在先不了解整个过程中去ctrl+c+v他人的博客代码,花费很多无用的时间去处理还不知道能不能跑的起来的代码. 2.本人比较喜 ...
- reduce的特殊用法
//计算数组中每个元素出现的次数var arr = ["apple","orange","apple","orange" ...
- 2) 十分钟学会android--建立第一个APP,执行Android程序
通过上一节课创建了一个Android的Hello World项目,项目默认包含一系列源文件,它让我们可以立即运行应用程序. 如何运行Android应用取决于两件事情:是否有一个Android设备和是否 ...