Say I want to count in binary until I have the highest number a set number of bytes will hold, how could I do that? It feels like there should be a pretty simple way, I just don't know it. I googled but was surprised to not find any examples.
For example, if I wanted to count to 1 byte I'd start with 00000001 add 1 and get 00000010, add 1 to get 00000011, etc until I get to 11111111.
Additionally, how could you do the same in hex? you start with 0x00, add one and output 0x01, the 0x02, 0x03, etc until you get to 0xFF?
Also, how can I output the values as a string (like my examples)?
Some psuedo-code:
byteSize = 3
counter = 0
while counter.size <= byteSize
print counter /* prints 00000001, 00000010, etc.
count += 1
loop
Update:
I'm not only concerned with displaying a number in another base, that was only part of it. I see my error in that the displaying function is what determines how the number is displayed (as Jeremy pointed out). So, that's parts not a problem.
Update 2:
I promise I'm not a complete moron. Here is the context:
It started today when I read this on reddit: http://www.elliottkember.com/kember_identity.html
Then, this: http://www.reddit.com/r/programming/comments/8iguu/md5_gamechallenge_for_you_reddit/
which led to this: http://www.olegkikin.com/md5game/
So, I figured you could just count in bits starting at different intervals and just let 'er run.