Ad
  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar
  • Default User Avatar

    Huge thanks for those few who came up with this (double dabble) algorithm. Today I learned something new.
    I think the best way to get your head around it is to look at it as a reverse of decimal to binary process.

    Decimal to binary (https://www.cuemath.com/numbers/decimal-to-binary/):
    To convert 13 to binary you need to:

    1. 13 / 2 = 6 remainder 1
    2. 6 / 2 = 3 remainder 0
    3. 3 / 2 = 1 remainder 1
    4. 1 / 2 = 0 remainder 1

    So if we get remainders from bottom to top we end up with 1101, which is a binary representation of 13

    If we use double dabble method, then we just put the above process in reverse.

    • our number is 1 1 0 1 (so we start with leftmost digit - 1 and continue to the right)
    1. 0 * 2 + 1 = 1 (does it remind you anything? Look at step 4 of decimal to binary process - 0 is quatinent and 1 is remainder)
    2. 1 * 2 + 1 = 3 (look at the step 3 of decimal to binary)
    3. 3 * 2 + 0 = 6
    4. 6 * 2 + 1 = 13

    One note: when using double dabble method we always start wit 0 * 2 (as there is no previous digit to the left-most digit of the binary number)

    Hope this helps...

  • Default User Avatar

    Makes perfect sense!
    Thank you!

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution