faqts : Computers : Programming : Languages : PHP : Common Problems

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

8 of 21 people (38%) answered Yes
Recently 2 of 10 people (20%) answered Yes


Please tell me how I can read 16 bit binary as an integer. Also please explain how to use pack and unpack functions for binary to integer and visavis

Jul 13th, 2000 11:25
Ben Udall, Rao Atluri,

If I understand your question correctly, the best way to convert
between an integer and binary is to use the bindec() and decbin()
$int = bindec($bin)
This function takes a string representation of a binary number
and converts it to an integer.
$bin = decbin($int)
This does the opposite, takes an integer and converts it to binary