How computers store negative numbers
To convert -11 from decimal to binary, we use two's complement representation for negative numbers (commonly used in computing).
Sign magnitude
When using sign-magnitude representation for negative binary numbers, the most significant bit (MSB) which is the leftmost bit is used as the sign bit:
• 0 = positive
• 1 = negative
The remaining bits represent the absolute value in binary.
One’s Complement
The one's complement of a binary number is a simple operation:
In essence, it's the bit-wise inverse of the original number.
How it works:
1. Identify the bits:Look at each digit (0 or 1) in the binary number.
2. Flip each bit:Replace every 0 with a 1 and every 1 with a 0.
Two's complement is, commonly used in computers. It allows for efficient arithmetic operations, including subtraction, by treating subtraction as addition with the two's complement of the subtrahend.
Here's how it works:
1. Representing Positive Numbers:
Positive numbers are represented in their standard binary form. The most significant bit is 0, indicating a positive number.
2. Finding Two's Complement:
To find the two's complement of a binary number (especially for negative numbers), you first take the one's complement by flipping all the bits (0s to 1s and 1s to 0s) and then add 1 to the result.
3. Representing Negative Numbers:
The MSB of a two's complement number is 1, indicating a negative value.
CONVERTING -11 FROM DECIMAL TO BINARY
Step 1: Convert +11 to Binary
Find the binary of 11:
2
11
2
5
R 1
2
2
R 1
2
1
R 0
2
0
R 1
• 1110=10112
We’ll represent this in 8 bits (standard for small integers):
• 1110=000010112
Step 2: Take the Two's Complement
To get -11:
1. Invert the bits:
00001011 → 11110100
2. Add 1:
11110100 + 1 = 11110101
-11 in 8-bit two's complement binary is:
11110101
Corresponding hexadecimal value
1111 0101
First Part
1111
(1 * 23) + (1 * 22) + (1 * 21) + (1 * 20)
8 + 4 + 2 + 1
15 = F
Second Part
(0 * 23) + (1 * 22) + (0 * 21) + (1 * 20)
4 + 1
5
Final answer
F5