You are on page 1of 22

MII1804 : Digital Electronics

3 -Number Systems (Cont)


Ika Candradewi
Dept. of Computer Science and Electronics
The Faculty of Mathematics and Natural Science
Number Systems
Standard number systems
– Decimal
– Binary
– Hexadecimal
– Octal
Binary Codes
– Binary Coded Decimal (BCD)
– Gray Codes
– ASCII
Representation of negative numbers
– Sign magnitude
– 1’s complement and 2’s complement
Arithmetic operations using 2’s complement
Sign- Magnitude
• Left most bit is the sin bit, remaining bits are
magnitude bits
• Examples :
Sign- Magnitude
• Find the Equivalent decimal of the Following sign-
magnitude binary

• Find the Equivalent sign-magnitude binary of thhe


following decimal numbers
Sign - Magnitude
• The most-significant bit (MSB) is the sign digit
• 0 ≡ positive
• 1 ≡ negative

• The remaining bits are the number’s magnitude


• Problem 1: Two representations for zero
• 0 = 0000 and also –0 = 1000

• Problem 2: Arithmetic is cumbersome


1’s Complement
• Negative numbers are the Complement of the
positive numbers and vice versa
• Example :
1’s Complement (Cont.)
• Given 1100 1110 in 1’s Complement, how to find its
equivalent decimal?
• Example :
1’s Complement (Cont.)
• Find the Equivalent decimal of the Following 1’s
Complement binary :

• Find the equivalent 1’s Complement binary of the


following decimal :
1’s Complement
• Negative number: Bitwise complement positive
number
• 0111 ≡ 710
• 1000 ≡ –710

• Solves the arithmetic problem

• Remaining problem: Two representations for zero


• 0 = 0000 and also –0 = 1111
2’s Complement
• 1’s complement incremented by 1
• Example :
2’s Complement (Cont.)
2’s Complement Example:
• 0111 ≡ 710
• 1001 ≡ –710 –1 0
–2 1111 0000 +1

• Number wheel –3 1110 0001 +2


1101 0010
–4 +3
• Only one zero! 1100 0011

– 5 1011 0100 + 4
• MSB is the sign digit 1010 0101
–6 1001 0110 +5
• 0 ≡ positive 1000 0111
–7 +6
• 1 ≡ negative –8 +7
2’s Complement (Cont.)
• Given 1100 1110 in 2’s Complement, how to find its
equivalent decimal ?
2’s Complement (Cont.)
• Find the equivalent decimal of the Following 2’s
Complement binary :

• Find the Equivalent 2’s Complement binary the


Following decimal :
2’s Complement (Cont.)
• Find the equivalent decimal of the Following 2’s
Complement binary :

• Find the Equivalent 2’s Complement binary the


Following decimal :
Example
• Fill in the Following table

• Why is there 3 standards in representing negative


numbers ?
1. There are limitation in sign-magnitude and 1’s
Complement representation, therefore, 2’s complement
representation is the standard today
2. Limitation of Sign Magnitude and 1’s Complement
 there are two representation of zero
Example
• What does te byte 0101 00002 means?
 50 (exadesimal)
 50 (BCD)
 120 (octal)
 80 (decimal equivalent of binary)
 0111 1000 (gray code equivalent)
 Caracter ‘P’ (ASCII equivalent)
 80 (decimal equivalent of Sign-magnitude)
 80 (decimal equivalent of 1’s complement)
 80 (decimal equivalent of 2’s Complement)
2’s Complement Arithmatic
• We will look only at Byte addition and
substraction of 2’s Complment number
• In Byte 2’s Complment number, the Largest
number tat can be represented is 0111 1111
(127) and the lowest is 1000 0000(-128)
• If addition or substraction exceeds 127 or -
128 then the result will be incorrect
• This Condition if incorrect result is called
overflow
2’s Complement Arithmatic (Cont.)
Range of Byte 2’s Complement

When adding / substracting


byte 2’s Complemnet number,
make sure the result is within
range
2’s Complement Arithmatic (Cont.)
• Complementing a complement  the original
number
• Arithmetic is easy
• Subtraction = negation and addition
• Easy to implement in hardware
2’s Complement Addition
2’s Complement Substraction
• Take the 2’s Complement of te subtrahend, then
do addition
• Example : 8 – 3
- Take 2’s complement of 3 => 1111 1101
- Do addition (now its 8 + (-3))
Digit Group
• Terminology for groups of bits

You might also like