6
26 == 64 < 119 < 27 == 128
So, starting with 26:
Power of 2 | Include? | Subtraction | Binary so Far |
---|---|---|---|
26 == 64 | 64 is less than 119 | 119 - 64 == 55 | 1 _ _ _ _ _ _ |
25 == 32 | 32 is less than 55 | 55 - 32 == 23 | 1 1 _ _ _ _ _ |
24 == 16 | 16 is less than 23 | 23 - 16 == 7 | 1 1 1 _ _ _ _ |
at this point, if you remember that 111 represents 7, you can jump to the end: | 1 1 1 0 1 1 1 |
So 119, represented in binary, is 110111.
Can the repeated subtraction method be used with negative integers?