node.js - 在 Node 中将 ieee754 转换为十进制

标签 node.js npm buffer ieee-754

我在 Node <Buffer 42 d9 00 00>中有一个缓冲区这应该代表小数 108.5。我正在使用此模块尝试解码缓冲区:https://github.com/feross/ieee754 .

ieee754.read = function (buffer, offset, isLE, mLen, nBytes)

参数含义如下:

buffer = the buffer
offset = offset into the buffer
value = value to set (only for write)
isLe = is little endian?
mLen = mantissa length
nBytes = number of bytes

我尝试读取值:ieee754.read(buffer, 0, false, 5832704, 4)但没有得到预期的结果。我认为我正确地调用了该函数,尽管我不确定 mLen论证。

最佳答案

[我发现] Node Buffer 类具有内置功能:buffer.readFloatBE(0)

关于node.js - 在 Node 中将 ieee754 转换为十进制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28538749/

相关文章:

node.js - Node-config 不会使用 Heroku 中的 custom-environment-variables.json 中的变量

javascript - 错误 1054 - 在 WHERE 中用作字段的变量被用作列

npm - 强制使用 1.9.8 PhantomJS 和 karma-phantomjs-launcher

node.js - 如何通过npm发布基于react的组件而不包含react?

angularjs - jwt中过期时如何刷新 token

javascript - 即使使用之前有效的代码,Bluebird 也不会调用 then()

postgresql - 如何在 PostGIS 中将缓冲区大小从度数更改为距离米?

c++ - 基于strlen的意外成功复制

linux - pyserial输入缓冲区

Node.js 实时内容与 DNode/shoe 以及所有有关负载平衡的内容