I would like to convert 14.4689 or 13.3开发者_StackOverflow616 to binary data (bits) in php. How Can I do this?
Thanks for helping
Stephane
Use pack('d',14.4689)
(double) or pack('f',14.4689)
(float)
look at the pack and unpack functions.
[adding example]
jcomeau@intrepid:~/rentacoder/harvard$ cat /tmp/test.php; /tmp/test.php
#!/usr/bin/php5-cgi
<?php
$packed = pack("d", 12.3456);
print_r(unpack("d", $packed));
?>
X-Powered-By: PHP/5.2.12-2
Content-type: text/html
Array
(
[1] => 12.3456
)
use this :
<?php
decbin(14.4689);
?>
精彩评论