Convert ieee754 to decimal in node

∥☆過路亽.° 提交于 2019-12-02 11:19:21

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!