Just flip out


#1

i did the exercise correctly but i don´t get why if we´re using some bitwise operator on a 8 bit number, we get back a 5 bit number

INSTRUCTIONS
.
In the editor is the 8 bit variable a. Use a bitmask and the value a in order to achieve a result where all of the bits in a are flipped. Be sure to print your answer as a bin() string!

ANSWER

a = 0b11101110
mask=0b11111111

desired= a^mask

print bin(desired)

RUN
0b10001


#2

Hi @maverb,

In the result, 0b00010001, the three 0s immediately following the 0b prefix are superfluous, and are discarded, just as such leading 0s would be discarded from a result in a decimal arithmetic operation. Therefore, 0b00010001 is represented as 0b10001.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.