Topic 6. Signed Number Format: Ce232 Digital System
Topic 6. Signed Number Format: Ce232 Digital System
Signed number
• Signed number represents negative number
• Computers only know binary, therefore we use signed number to
understand how computers represents and computes negative number
• There are 2 method
• Signed magnitude
• Complements : one’s complement and two’s complement
Signed magnitude
+ represented by zero
- represented by 1
Disadvantages
• Range only from -2(n-1) to +2(n-1)-1
Example : the representation for 4 bits signed number ( 1 for sign bit and 3
bits for magnitude bits) is
Whereas, in non signed number the range for 4 bit binary is from 0 tp 15
Example.
1’s Complement
• Complementing each digit in binary number
• Positive number remains the same
• Negative number is represented by complementing every bits
• Range -2(n-1) to +2(n-1)-1
Example.
Positive number (9)10 = (1001)2,
Negative number (-9)10 = (0110)2,
Steps
• Take 1’s complement for subtrahend, add it to the minuend
• If carry is not generated, the result is said to be negative & is in 1’s complement
form, take 1’s complement again to get the magnitude of the actual result
• If carry is generated, the result is positive, add 1 it to get the actual result
13 CE232 Digital Systems
6.2 1’s and 2’s Complement
Example.
Find 3 − 12 using 1’s complement
Example.
Find 54 − 72 using 1’s complement
Example.
Find 12 − 3 using 1’s complement
-3 (using 1’s complement) → 1100 ; 12 → 1100
1100
1100+
1 1 0 0 0 → carry is generated
1+
1 0 0 1 → the result is 9
Example.
Find 48 − 28 using 1’s complement
48 → 110000 ; -28 (using 1’s complement) → 100011
110000
100011+
1 0 1 0 0 1 1→ carry is generated, add it to the result
1+
0 1 0 1 0 0 → the answer is 20
2’s Complement
• Complementing each digit in binary number and add by 1
• Positive number remains the same
• Negative number is represented by complementing every bits and adding 1
to the complemented bit
• Range -2(n-1) to +2(n-1)-1
• The main difference between 1′ s complement and 2′ s complement is that
1′ s complement has two representations of 0, while 2’s complement only
have 1 representation for 0
18 CE232 Digital Systems
6.2 1’s and 2’s Complement
Example.
Positive number (9)10 = (1001)2,
Negative number (-9)10 = (0111)2,
Steps
• Take 2’s complement for subtrahend, add it to the minuend
• If carry is not generated, the result is said to be negative & is in 2’s complement
form. Take 2’s complement again to get the magnitude of the actual result
• If carry is generated, discard the carry
20 CE232 Digital Systems
6.2 1’s and 2’s Complement
Example.
Find 48 − 28 using 2’s complement
48 → 110000 ; -28 (using 2’s complement) → 100100
110000
100100+
1 0 1 0 1 0 0→ carry is generated, discard the carry, the answer is 010100
(20)
Example.
Find (111000)2 −(101001)2
(111000)2 − 101001 2 = 56 − 41
Example.
Find 54 − 72 using 2’s complement
• There are three parts of a fixed-point number representation: the sign field,
integer field, and fractional field
Example.
Represent fixed point of unsigned binary number 0110110 using 4 integer
bits and 3 fractional bits
0110. 110
6 0.75
Example.
Represent (-7.5) using 8 bit binary representation with 4 digits integer and 4
fraction bit (using 2’s complement)
(7,5)10 → (111.1)2 → (0111.1000)
2′ 𝑠 𝑐𝑜𝑚𝑝𝑙𝑒𝑚𝑒𝑛𝑡
1000.1000
Example.
Compute 0.75 +(-0.625) using 8 bits fixed point number
(0.75)10 → (0000.1100)2
(0.625)10 → (0000.1010)2
2′ 𝑠 𝑐𝑜𝑚𝑝𝑙𝑒𝑚𝑒𝑛𝑡
(1111.0110)2
0000.1100
1111.0110 +
0000.0010
29 CE232 Digital Systems
“
6.4 Floating Point IEEE
754
6.4 Floating Point IEEE 754
• IEEE Standard 754 floating point is the most common representation today
for real numbers on computers
• Makes particularly efficient use of the computer to represent extremely large
or small value
• Recall scientific notation format
• a value whose magnitude is in the range of 1≤n<10
• a power of 10
• 3498523 is written as 3.498523×106
• −0.0432 is written as −4.32×10−2
• It has 3 components
• The sign : 0 represents a positive number while 1 represents a negative number
• The exponent : to represent both positive and negative exponents.
• The mantissa : The mantissa is part of a number in scientific notation or a floating-point
number
Example.
Example.
Example.
Single precision
Double precision
The difference
Example.
Convert 19.25 into IEEE 754 standard 32-bit floating-point binary
Step 1. Determine the sign bit
Positive number → sign bit = 0
Step 2. Convert to pure binary
Example.
Convert -123.3 into IEEE
754 standard 32-bit
floating-point binary
Step 1. Determine the
sign bit
Sign bit = 1
Step 2. Convert to pure
binary
Example.
Convert 0 10000100 11010100000000000000000
Step 1. Determine the sign bit
0 → positive
Step 2. Determine the exponent in decimal
(100000100)2 = (132)10
Step 3. Remove the exponent bias
132 − 127 = 5
Example.
Convert 1 00001001 000110010000000000000
Step 1. Determine the sign bit
1 → negative
Step 2. Determine the exponent in decimal
(00001001)2 = (9)10
Step 3. Remove the exponent bias
9 − 127 = −118
Reserved value
M. Morris Mano, Digital Design, 5th ed, Prentice Hall, 2012, Chapter 1
Next Topic : Combinational Logic
Circuit