开发者

How To Convert double/binary and vice versa?

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);
?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜