Objective
Computers store negative integers in two's complement: with n bits, the value -x is stored as 2**n - x. The result is the same as keeping the lowest n bits of x.
Instructions
- The first line has the number
tof cases. Each case is a line withbits(number of bits) and an integerxthat fits in that number of signed bits. - Show
xin two's complement with exactlybitsbits (leading zeros included).
3
8 5
8 -1
4 -8
00000101
11111111
1000
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise