Encoding and decoding IEEE 754 floats in JavaScript

前端 未结 5 800
故里飘歌
故里飘歌 2021-01-05 04:29

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 ha

5条回答
  •  猫巷女王i
    2021-01-05 05:10

    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

提交回复
热议问题