perl CGI (3)
Visual Basic (1)
How do I convert bits into ints?
This article has not been rated yet. After reading, feel free to leave comments and rate it.
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: http://www.perldoc.com/perl5.6.1/pod/func/pack.html