在节点中将ieee754转换为十进制 [英] Convert ieee754 to decimal in node
问题描述
我在节点< Buffer 42 d9 00 00>
中有一个缓冲区,该缓冲区应该代表十进制108.5。我正在使用此模块尝试对缓冲区进行解码: https://github.com/feross/ieee754 。
I have a buffer in node <Buffer 42 d9 00 00>
that is supposed to represent the decimal 108.5. I am using this module to try and decode the buffer: 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
参数,但我认为我正确调用了该函数。
I try to read the value: ieee754.read(buffer, 0, false, 5832704, 4)
but am not getting the expected result. I think I am calling the function correctly, although I am unsure about the mLen
argument.
推荐答案
[我发现]节点Buffer类具有内置的功能: buffer.readFloatBE(0)
。
[I discovered that] the node Buffer class has that ability built in: buffer.readFloatBE(0)
.
这篇关于在节点中将ieee754转换为十进制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!