can anyone here give me a c++ example of result of a integer in base 2,4 and 8 please..
i am working on a program on this.
Printable View
can anyone here give me a c++ example of result of a integer in base 2,4 and 8 please..
i am working on a program on this.
What do you mean by "result of a integer in base 2,4 and 8"?
Well
89
in base 8 is:
1 * 8 ^ 0 + 3 * 8 ^ 1 + 1 * 8 ^ 2
in base 4:
1 * 4 ^ 0 + 2 * 4 ^ 1 + 1 * 4 ^ 2 + 1 * 4 ^ 3
in base 2:
1 * 2 ^ 0 + 0 * 2 ^ 1 + 0 * 2 ^ 2 + 1 * 2 ^ 3 + 1 * 2 ^ 4 + 0 * 2 ^ 5 + 1 * 2 ^ 6
See a pattern?
You can use modulus and division in a loop to obtain the multipliers.