| Programming C# C++ (7) Delphi (604) Java (8) JavaScript (55) perl (40) mysql (3) perl CGI (3) php (12) VBScript (1) Visual Basic (1) |
How do I convert bits into ints?
Question: How can I convert a number from binary format (0 and 1) to decimal?Answer: You need to use pack() the data to an eight bit binary structure then unpack it to the desired target structure with unpack() - or if the target is decimal, you can use ord().A few words on pack(). This function is very useful when processing CGI posted data, since this is often escaped. The first argument in pack() is a template. There are quite a few values - for a full documentation look here:
Comments:
|