4
24 == 16 < 18 < 25 == 32
From the above, it is easy to decide that 18, in binary, is 10010.
The leftmost bit (the high order bit) of a binary representation of an integer corresponds to the highest power of two that "fits" into the integer. For example:
Integer | Too Big | Best Fit | Too Small | Leftmost Bit |
---|---|---|---|---|
16 | 25=32 | 24=16 | 23=8 | 1 _ _ _ _ |
18 | 25=32 | 24=16 | 23=8 | 1 _ _ _ _ |
23 | 25=32 | 24=16 | 23=8 | 1 _ _ _ _ |
49 | 26=64 | 25=32 | 24=16 | 1 _ _ _ _ _ |
52 | 26=64 | 25=32 | 24=16 | 1 _ _ _ _ _ |
63 | 26=64 | 25=32 | 24=16 | 1 _ _ _ _ _ |
64 | 27=128 | 26=64 | 25=32 | 1 _ _ _ _ _ _ |
Represent 17 in binary.