使用JavaScript编码和解码IEEE 754浮点数 [英] Encoding and decoding IEEE 754 floats in JavaScript
问题描述
是否有任何现有的库可以执行此操作,还是必须阅读规范并自行实施?或者我应该写一个C模块来完成它?注意,从节点0.6开始,这个功能包含在核心库中,所以这是最好的办法。
请参阅 http://nodejs.org/docs/latest/api/buffer.html 了解详细信息。
如果您正在阅读/编写二进制数据结构,你可能会考虑使用友好的包装这个功能,使事情更容易阅读和维护。插件如下: https://github.com/dobesv/node-binstruct
I need to encode and decode IEEE 754 floats and doubles from binary in node.js to parse a network protocol.
Are there any existing libraries that do this, or do I have to read the spec and implement it myself? Or should I write a C module to do it?
Note that as of node 0.6 this functionality is included in the core library, so that is the new best way to do it.
See http://nodejs.org/docs/latest/api/buffer.html for details.
If you are reading/writing binary data structures you might consider using a friendly wrapper around this functionality to make things easier to read and maintain. Plug follows: https://github.com/dobesv/node-binstruct
这篇关于使用JavaScript编码和解码IEEE 754浮点数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!