Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do you count in another base?
    text
    copied!<p>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.</p> <p>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. </p> <p>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?</p> <p>Also, how can I output the values as a string (like my examples)? </p> <p>Some psuedo-code:</p> <pre><code>byteSize = 3 counter = 0 while counter.size &lt;= byteSize print counter /* prints 00000001, 00000010, etc. count += 1 loop </code></pre> <h2>Update:</h2> <p>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.</p> <h2>Update 2:</h2> <p>I promise I'm not a complete moron. Here is the context:</p> <p>It started today when I read this on reddit: <a href="http://www.elliottkember.com/kember_identity.html" rel="nofollow noreferrer">http://www.elliottkember.com/kember_identity.html</a></p> <p>Then, this: <a href="http://www.reddit.com/r/programming/comments/8iguu/md5_gamechallenge_for_you_reddit/" rel="nofollow noreferrer">http://www.reddit.com/r/programming/comments/8iguu/md5_gamechallenge_for_you_reddit/</a></p> <p>which led to this: <a href="http://www.olegkikin.com/md5game/" rel="nofollow noreferrer">http://www.olegkikin.com/md5game/</a></p> <p>So, I figured you could just count in bits starting at different intervals and just let 'er run.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload