Challenge: Taking One's and Two's Complements
Solve the challenge to check your understanding of calculating the one's and two's complements of a given decimal number.
We'll cover the following
Requirements
Given a decimal value, for example, –10, perform one’s complement and two’s complement on it without using a computer or calculator.
Instructions
-
Convert the decimal value to binary using the signed 8-bit representation.
-
Perform one’s complement on the binary value by flipping all the bits.
-
Perform two’s complement on the binary value by first adding 1 to the one’s complement result.
Get hands-on with 1400+ tech skills courses.