Max Stern Max Stern - 10 months ago 89
Javascript Question

Parse HEX float

I have integer, for example,


How I can get HEX float (
) from it?

JS hasn't
type, so I don't know how to do this conversion.

Thank you.

Answer Source

If you want a hex string, try this:

> var b = new Buffer(4);
> b.writeFloatLE(4060, 0)
> b.toString('hex')

And the other way (using your input):

> Buffer('34C87D45', 'hex').readFloatLE(0)