You are on page 1of 4

COE/EE 243 Lecture #4

Binary Arithmatic--continued

** One's-Complement Addition and Subtraction
When adding 1's-complement numbers, add the carry out
to the partial sum to get the final result (end-around carry).
Partial Proof:
-A + B (assume B > A)
n n
= (2 - 1 - A) + B = 2 + (B - A) - 1
n
an end-around carry same as subtracting 2 and adding 1.
Overflow same as for 2's-complement case.
+3 0011 +5 0101 +5 0101
+4 0100 +6 0110 -6 1001
-------- -------- --------
+7 0111 +11 1011 -1 1110
(overflow)
-3 1100
-4 1011
--------
0111
1
----
-7 1000
Subtraction generally performed by complementing subtrahend
and adding.
Multiplication
1101 = 13
x0101 = 5
-----
1101
0000
1101
0000
------
1000001 = 65
Basically a repeated shift and add process.
Example: Parallel Multiplier (Multiply 1101 by 1011)
1101 is multiplicand, 1011 is multiplier.
1101 13
1011 11
----
0000
1101 Add 0000 (initial state) + 1*1101
----
1101 (sum)
1101 Shift & Add 1*1101
-----
100111
0000 Shift & Add 0 * 1101
------
100111
1101 Shift & Add
-------
10001111 143
Binary Divider:
Divisor 0101 <--Quotient
\ ________
110 | 100010 Dividend 100 < 110, so first bit in quotient is 0
----| 110
-----
101 101<110 so another 0
000
---
1010
110
----
100 Remainder
In some cases the Remainder is more important than the Quotient. For example
when measuring an angle, you want the angle between 0 and 360 degrees (or -180
and +180 degrees even). So you divide by 360 repeatedly (binary arithmatic
in an electronic controller) until number is less than 360, and the remainder
is the angle you want.
The substractions above would use a subtractor circuit based on 1's or 2's
complement.
** Binary Codes for Decimal Numbers
A code is simply an alternate representation for something.
A Binary-Coded-Decimal (BCD) is formed by replacing each
decimal digit by its 4-bit binary equivalent:
342.61 --> 0011 0100 0010 . 0110 0001
** Gray Code
The Gray code has the characteristic that any two consecutive
numbers differ in only one bit position.
Binary sequence -> 000 001 010 011 100 101 110 111
Gray code sequence -> 000 001 011 010 110 111 101 100
n
The first 2 code words of an n-bit Gray code equal the code
words of an (n-1)-bit Gray code with a leading 0 appended.
n
The second 2 code words of an n-bit Gray code equal the code
words of an (n-1)-bit Gray code, written in reverse order
with a leading 1 appended.
0 1
00 01 11 10
000 001 011 010 110 111 101 100
Good for error checking. Used to be called "reflected code"
Usually works best when the signal is one that is a running
count.
Another method for error checking is to add a "parity bit"
The parity bit as added to a number before it is transmitted
to ensure that the number of 1's is either odd or even. The
receiver then checks the parity upon receipt. Used in most
modems.
For example if one wanted

odd even
Message Parity Parity
00 1 0 total number or 1's odd or even
01 0 1
11 1 0
Table 2-9 on page 49 shows several possible decimal codes.
** Character Codes
The American Standard Code for Information Interchange (ASCII)
is a 7-bit code often used to represent letters, numbers, and
other symbols for storage in computers.
A is 1000001 (65 decimal)
a is 1100001 (97 decimal)
0 is 0110000 (48 decimal)
? is 0111111 (63 decimal)
See Table 2-11, page 54.
** Basic Digital Circuits
Chapter 3 in text. I'm not going through the entire chapter.
The parts that you should remember are covered here.
Digital circuits are based on using 0 and 1 to define logic
levels (and to implement binary codes)
Analog circuitry is used to create these 2 logic states.
Examples:
Switches/Relays (still used in many places)
Switch open --> Logic 0
Swithc closed--> Logic 1

Fiber optic lines: Light off = 0
Light on = 1

CDROM --> no pit in surface = 0
pit in surface =1
DRAM (dynamic ramdom access memory)--> capactor discharged = 0
capacitor charged = 1
ROM (read only memory) --> fuse blown =0
fuse intact = 1
(ROM initally all 1's, and write to it by blowing
fuses electrically. Some can be reset electrically or
with ultraviolet light)
However, in many circuits, logic levels are 2 different voltage levels

You might also like