javascript float from/to bits

后端 未结 5 1103
孤独总比滥情好
孤独总比滥情好 2020-12-01 09:50

I am trying to perform something that is brain-dead simple in any other language but not javascript: get the bits out of float (and the other way around).

In C/C++ i

5条回答
  •  醉话见心
    2020-12-01 10:06

    function DoubleToIEEE(f)
    {
        var buf = new ArrayBuffer(8);
        (new Float64Array(buf))[0] = f;
        return [ (new Uint32Array(buf))[0] ,(new Uint32Array(buf))[1] ];
    }
    

提交回复
热议问题