Val*_*das 2 php floating-point byte
如何在php中从字节转换为浮点数?就像在Java中一样
int i = (byte3 & 0xff) << 24 | (byte2 & 0xff) << 16 | (byte1 & 0xff) << 8 | byte0 & 0xff;
Float.intBitsToFloat(i);
Run Code Online (Sandbox Code Playgroud)
可能有更直接的方式,但是你走了:
<?php
var_dump(unpack('f', pack('i', 1059760811)));
?>
Run Code Online (Sandbox Code Playgroud)
当然,这取决于机器,但我不知道任何运行PHP的机器不使用IEEE 754浮点数.