Question
Why does my code not print the base 10 equivalent of the binary string?
Answer
There are two parts you need to do correctly to print the base 10 equivalent of the binary number 11001001
.
- We must provide the first parameter as the string of the binary number we want to convert
- We must provide the second parameter as the base we’re currently giving as the first parameter, which is
2
in this case
1 Like
I expected “201” to be the base 10 equivalent for the binary “11001001”, but instead the system printed on the console the same binary (“11001001”) that was supposed to be converted in a base 10 number and marked the exercise as correct.
I’ve arrived to 201 this way (please, tell me if I’m wrong, thx):
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1
1 | 1 | 0 | 0 | 1 | 0 | 0 | 1
ON | ON | off | off |ON| off | off | ON
128 + 64 + 0 + 0 + 8 + 0 + 0 + 1
128 + 64 + 8 + 1 = 201
8 Likes
When I returned from here to the lesson’s tab, the platform reconnected to CC and “magically” this time the console showed the correct result (“201”).
1 Like