<?php
$binarydata32 = pack('H*','00000000');
$float32 = unpack("f", $binarydata32); $binarydata64 = pack('H*','0000000000000000');
$float64 = unpack("d", $binarydata64); ?>
I get 0 both for 32-bit and 64-bit numbers.
But, please don't use your own "functions" to "convert" from float to binary and vice versa. Looping performance in PHP is horrible. Using pack/unpack you use processor's encoding, which is always correct. In C++ you can access the same 32/64 data as either float/double or 32/64 bit integer. No "conversions".
To get binary encoding:
<?php
$float32 = pack("f", 5300231);
$binarydata32 =unpack('H*',$float32); $float64 = pack("d", 5300231);
$binarydata64 =unpack('H*',$float64); ?>
And my example from half a year ago:
<?php
$binarydata32 = pack('H*','0EC0A14A');
$float32 = unpack("f", $binarydata32); $binarydata64 = pack('H*','000000C001385441');
$float64 = unpack("d", $binarydata64); ?>
And please mind the Big and Little endian boys...