Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Not sure if I understood your problem correctly, but assuming you have a natural number x that can be represented with m (e.g., 20) bits, but you have only arrays of n bits at your disposal (say, bytes, i.e. 8-bit arrays), the amount of arrays you need is simply m/n rounded up to the next natural number. For a number that has 20 digits in binary format, that would be 3 bytes.</p> <p>E.g. if your number is</p> <pre><code>1001 01101100 10110100, </code></pre> <p>you could store it as</p> <pre><code>00001001 01101100 10110100. </code></pre> <p>What you have done is to </p> <ol> <li><p>(integer-) divide your number by 100000000 (10^1000, or 2^8 in decimal system), write down the remainder, truncate the result</p></li> <li><p>(integer-) divide the result of 1. by 100000000, write down the remainder, truncate the result</p></li> <li><p>(integer-) divide the result of 2. by 100000000, write down the remainder, truncate the result</p></li> <li><p>nothing interesting to do anymore because the result of 3 was 0.</p></li> </ol> <p>Assuming we talk about natural numbers here, in the decimal system the above would look like this:</p> <pre><code>1. 617652/256 = 2412 remainder 180 (10110100 in binary system) 2. 2412/256 = 9 remainder 108 (01101100 in binary system) 3. 9/256 = 0 remainder 9 (00001101 in binary system) </code></pre> <p>So what you are doing is</p> <pre><code>while (number &gt; 0) { divide number by 2^n remember remainder truncate number } </code></pre> <p>Restoring the original number is left as an exercise :)</p> <p>This is actually a problem that comes up whenever you want to deal with very large integer numbers on the computer. I guess a good place to start looking for further information might be <a href="http://en.wikipedia.org/wiki/Positional_notation" rel="nofollow">http://en.wikipedia.org/wiki/Positional_notation</a>.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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