2
Contributors
1
Reply
4
Views
7 Years
Discussion Span
Last Post by Adak
0

Remember the number line for bianry:

2^7  2^6  2^5  2^4  2^3  2^2  2^1  2^0

And our number line works the exact same way, just substitute a 10 for the left 2's, above (left hand side only in the case of 2^2, of course).

So that indicates that we can, in a loop, find the greatest power of the base (be it 2 or to), to begin "decomposing" any number.

Then subtracting that amount from the original number, we loop back, and look for the next largest value of the base ^the exponent.

It might help you to look at char's: What is their greatest value? What does sizeof(char) tell you about their size, in bytes?

How does their size, reflect on their maximum value?

What is a char's max value on your system? You can look for "limits.h", and the macro MAX_CHAR or CHAR_MAX, but you can also just:

char i=0;

while(++i > 0);
printf(%d", i-1);

print that out on paper in binary, and see how it looks. Print out the same using the sizeof(char), where each bit of the byte, has the value 1.

What do you notice? ;)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.