Convert ieee754 to decimal in node

2019-02-28 07:43发布

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)

The arguments mean the following:

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

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.

1条回答
太酷不给撩
2楼-- · 2019-02-28 08:08

[I discovered that] the node Buffer class has that ability built in: buffer.readFloatBE(0).

查看更多
登录 后发表回答