Training, Open Source computer languages

This is page ... versa.html

Our email: • Phone: 01144 1225 708225

Conversion of Hex bytes to binary and vice versa

Posted by (, 9 November 2006
Hi all,

I have to convert a hex byte [eg: 0x2A] into its binary form [eg:00101010]. The input is always only one byte that is 8 bits.

I tried using pack() and unpack(). But i am unable to get desired results.

The desired output should look like the following:

0x0a => 00001010
0x23 => 00100011

Can anyone suggest me for the same?

Posted by admin (Graham Ellis), 9 November 2006
I understand that this query has now been answered ... see the next thread for a related issue / discussion.

This page is a thread posted to the opentalk forum at and archived here for reference. To jump to the archive index please follow this link.

© WELL HOUSE CONSULTANTS LTD., 2015: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 899360 • EMAIL: • WEB: • SKYPE: wellho