You are on page 1of 15

EEE 223

Digital Electronics
Instructor: Tishna Sabrina
Fall 2014
Lecture 2
Binary Systems

Binary Numbers

10/1/2014

1-bit binary
Number

2-bit binary
Number

3-bit binary
Number

4-bit binary
Number

0
1

00
01
10
11

000
001
010
011
100
101
110
111

0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111

Digital Electronics: Lecture 2

Signed Binary Number

First decide on the number of bits to represent


the signed binary number.
MSB determines the sign of the binary number.

3 different methods to represent a signed binary


number

1 in MSB represent a negative number


0 in MSB represent a positive number

Signed magnitude
1s complement form
2s complement form

Stick with any one of the methods while


performing arithmetic operations, never mix and
match.

10/1/2014

Digital Electronics: Lecture 2

Signed Binary Number

Signed magnitude

10/1/2014

MSB is used as sign bit and the rest of the bits


represents the magnitude.
Used in ordinary arithmetic, but is awkward when
employed in computer arithmetic because of the
separate handling of the sign and the magnitude.
+0 and 0 have different representation
+8510 = 010101012

-8510 = 110101012

+010 = 000000002

-010 = 100000002

Digital Electronics: Lecture 2

Signed Binary Number

1s complement form

10/1/2014

Complement each bit to generate it.


May be used for computer arithmetic.
+0 and 0 have different representation

+8510 = 010101012

-8510 = 101010102

+010 = 000000002

-010 = 111111112

Digital Electronics: Lecture 2

Signed Binary Number

2s complement

10/1/2014

Complement each bit and then add 1 to generate


the 2s complement number.
Used in most computers and digital systems
+0 and 0 have same representation

+8510 = 010101012

-8510 = 101010112

+010 = 000000002

-010 = 000000002

Digital Electronics: Lecture 2

Binary Arithmetic

Binary Addition

Unlike decimal addition, there is little to memorize in the


way of rules for the addition of binary bits.
0+0=0
1+0=1
Just as with decimal addition, when the
0+1=1
sum in one column is a two-bit (two-digit)
1 + 1 = 10
number, the least significant figure is
1 + 1 + 1 = 11
written as part of the total sum and the
most significant figure is "carried" to the
next left column.

1001101
+ 0010010
---------------1011111

10/1/2014

11 1 <--- Carry bits -----> 11


1001001
1000111
+ 0011001
+ 0010110
----------------------------------1100010
1100010

Digital Electronics: Lecture 2

Binary Subtraction

Using 2s complement method


Represent the subtrahend in 2s complement form
and simply add to the minuend.

A B = A + (-B) = A + 2s complement of B

Inspect the result for an end carry:

If an end carry occurs, discard it


If no end carry occurs, take the 2s complement of the
number obtained and place a negative sign in front

+6
+6
- +3
+ (-3)
------------+3
+3
Answer: 0011
10/1/2014

0110
+ 1101
---------10011

+3
3
0011
-4
+ (-4)
+ 1100
----------------------1
-1
1111
Answer: -0001
Digital Electronics: Lecture 2

Binary Subtraction

Using 1s complement method

Represent the subtrahend in 1s complement form


and simply add to the minuend.

A B = A + (-B) = A + 1s complement of B

Inspect the result for an end carry:

If an end carry occurs, add 1 to LSB as end-around carry


If no end carry occurs, take the 1s complement of the
number obtained and place a negative sign in front

+6
- +3
------+3

10/1/2014

+6
+ (-3)
------+3

0110
+ 1100
---------10010
+1
--------0011

+3
3
-4 +(-4)
-------------1
-1
Answer: -0001

Digital Electronics: Lecture 2

0011
+ 1011
----------1110

Binary Multiplication

Shift and add multiplication as in primary


school
7
x 3
------21

10/1/2014

0111
0011
------------------0111
0111x
0000xx
0000xxx
------------------00010101

Digital Electronics: Lecture 2

10

Binary Division

Shift and subtract as in primary school again.

10/1/2014

Digital Electronics: Lecture 2

11

Binary Codes

BCD

Binary Coded Decimal


Codes 0~9 using 4-bit unsigned binary representation
0000 thru 1001
(185)10 = ( 0001 1000 0101)BCD = (10111001)2
Code words 1010 thru 1111 are not used

BCD Addition

10/1/2014

Similar to adding 4-bit unsigned binary


A correction must be made if result exceeds 1001
Correction is made by adding 6 (i.e. 0110)

Digital Electronics: Lecture 2

12

BCD Addition

When the value of resultant 4 bits>910, add 610 with


it to get final result
When the value of resultant 4 bits<910, but a carry
is generated, then again add 610 with it to get final
result
9
+4
------+13

1001
0100
------1101>910

1101
+ 0110
---------00010011

9
+9
------18

1 3

10/1/2014

Digital Electronics: Lecture 2

1001
+1001
-----------10010

10010
+ 0110
----------00011000

1 8

13

Binary Codes

Gray Code

10/1/2014

Only 1-bit changes


between two
neighboring numbers
This prevents any
unknown state while
transitioning.

Digital Electronics: Lecture 2

14

Binary Codes

Excess 3-Code
2421
1-out-of-n code
ASCII Code
Biquinary

10/1/2014

Digital Electronics: Lecture 2

15

You might also like