On a side note, a byte is not always 8 bits...
Here is code I wrote that uses the correct byte size depending on ur system...static int size = sizeof(unsigned long) * 8;
Code:template <typename ChildType> string ConvtoBin (ChildType eData) { string bits; for (int a = sizeof(eData) * CHAR_BIT; a > 0; a--) bits += ((eData >> a) & 1) + 48; return bits; }