问题
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:
[I discovered that] the node Buffer class has that ability built in: buffer.readFloatBE(0)
.
来源:https://stackoverflow.com/questions/28538749/convert-ieee754-to-decimal-in-node