C++ Print Binary Function

March 19, 2007

A while back I used a function I found on the web to print off a binary representation of a number while I was working on a blowfish implementation in C++. I haven’t finished the blowfish, but I made some changes to the binary function, and thought I’d post it since it is a handy thing to have.

Essentially all I did was set it so it grouped the digits by 4 and padded out the MSB set with 0’s so they all line up.

Here’s an example program, and the results.

Categories: Geek
Tags: , ,

Leave A Comment

Your email will not be published.