0% found this document useful (0 votes)
83 views26 pages

Operations On Numbers

The document discusses various binary operations including addition, multiplication, complements, subtraction using complements, signed and unsigned binary numbers, binary coded decimal, character representation using ASCII, error detection using parity bits, and binary storage in registers. Binary addition and multiplication follow the same rules as decimal but are simpler. Complements are used for subtraction by adding the complement. Signed numbers use the sign-magnitude or two's complement convention. BCD encodes each decimal digit in 4 bits. ASCII encodes 128 characters in 7 bits. Parity bits detect errors in data transmission. Registers store and transfer binary information for processing. Exercises are provided to perform subtraction using radix and diminished radix complements in various bases.

Uploaded by

Reyn Mayoyo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
83 views26 pages

Operations On Numbers

The document discusses various binary operations including addition, multiplication, complements, subtraction using complements, signed and unsigned binary numbers, binary coded decimal, character representation using ASCII, error detection using parity bits, and binary storage in registers. Binary addition and multiplication follow the same rules as decimal but are simpler. Complements are used for subtraction by adding the complement. Signed numbers use the sign-magnitude or two's complement convention. BCD encodes each decimal digit in 4 bits. ASCII encodes 128 characters in 7 bits. Parity bits detect errors in data transmission. Registers store and transfer binary information for processing. Exercises are provided to perform subtraction using radix and diminished radix complements in various bases.

Uploaded by

Reyn Mayoyo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 26

Operations on Numbers

Binary Addition
• Binary addition is very simple.
• Same rule as decimal
+ 0 1

0 0 1

1 1 10

1 11 1 1 1 carries
11 1 1 0 1
+ 1 0 1 1 1
---------------------
1 0 1 0 1 0 0
Multiplication of Binary numbers
• Much the same as decimal multiplication,
except that the multiplication operations
are much simpler…

1 0 1 1 1
* 0 1 X 1 0 1 0
-----------------------
0 0 0 0 0 0 0 0
1 0 1 1 1
1 0 1 0 0 0 0 0
1 0 1 1 1
-----------------------
1 1 1 0 0 1 1 0
Complements
• Common use of complement: subtraction
operation.
• Perform subtraction through the addition
operation.

• Two types of complements for each base-


r system:
—r’s complement ( radix complement )
—(r-1)’s complement ( diminished radix
complement)
(r-1)’s Complements
• (r-1)’s complement for a number N with
n digits in base-r numbering system is
defined as:
(rn -1 ) – N
• Example #1: Find the 9’s complement
of 12389:
= (105 -1 ) - 12389
= 99999 -12389 = 87610
• Example #2: Find the 9’s complement
of 1234:
= (104 -1) – 1234 = 9999 -1234
= 8765
(r-1)’s Complements
• Example #3: Find the 1’s complement of
1011001:
= (27 – 1 ) – 101 1001
= 111 1111 – 101 1001 = 010 0110

• Notice that the 1’s complement of binary


numbers is formed by changing 1’s to 0’s
and 0’s to 1’s
• Example: 1’s complement of 0001111 is
1110000.
(r’s complement)
• (r’s) complement for number N in base r
with n digits is defined as rn – N
• Also, r’s complement= ( r-1)’s
complement +1

• Example #1: Find the 10’s complement


of 2389:
=9999 - 2389 = 7610 + 1 = 7611
• Example #2: Find the 2’s complement
of 10 1100:
= 11 1111 - 10 1100 = 01 0011 + 1
= 010100
Subtraction with complements
(Unsigned Numbers)
• Use the following algorithms:
1. Add M to r’s complement of N

2. If M>=N, then subtract the sum to rn


to form the result.

3. if M<N place a negative sign ―-‖ in


front of r’s complement of the result
Unsigned Example #1:
• Do the operation: 3250 - 72532

M = 03250
10’s complement of N = + 27468
------------
30718
Since N is > M the result is:
- (10’s complement 30718) =-69282
Unsigned Example #2:
• Perform the operation using 2’s
complement: 1010100 - 1000011
Solution:
X = 1010100 = 101 0100 (copy)
- Y = 1000011 =+ 011 1101 (2’s)
1 001 0001
- 1 000 0000
001 0001
Signed Binary Numbers
• 01001 can be considered unsigned
binary = 9 or signed binary = +9

• But, 11001 can be considered unsigned


binary = 25 or signed binary = -9
• Signed numbers uses 0 for ―+‖ and 1 for
―-‖ , this system is called Signed-
magnitude convention
Signed Binary Numbers
• All negative numbers have 1 in leftmost
bit
• Signed magnitude is mostly used in
ordinary arithmetic.
• The 1’s complement is mostly used in
logical operations.
• The 2’s complement is mostly used in
computer arithmetic.
Decimal signed-2’s signed-1’s signed
complement complement magnitude
-------- ----------- ------------- -----------
+7 0111 0111 0111
+2 0010 0010 0010
+1 0001 0001 0001
+0 0000 0000 0000
-0 --- 1111 1000
-1 1111 1110 1001
-2 1110 1101 1010
-7 1001 1000 1111
-8 1000 ------- ------
Binary Coded Decimal (BCD)
• Uses 4 bits to encode one decimal digit
• Example: (4321)10
= 0100 0011 0010 0001

• Invalid digits: 1010, 1011,1100,1101,


1110,and 1111.
BCD Arithmetic Rules:
1. Add 2 BCD numbers using regular binary
addition.
2. Check each nibble (4-bit), if result is
greater than 9, then add 6 to it.
3. If there is a carry between 2 nibble or
coming from 2th nibble add 6.
BCD Addition

Example: 27 0010 0111


+ 34 0011 0100
------ -----------------
61 0101 1011 > 9
+ 0110 + 6
----------------
0110 0001 (61)
BCD Addition

Example: 1 carry
59 0101 1001
+ 39 0011 1001
----------------
1001 0010
0110 (+6)
----------------
1001 1000 (98)
BCD Addition

1 1 carry
98 1001 1000
+ 89 1000 1001
---------------
1 0010 0001
+ 0110 0110 (+6 6)
---------------
1 1000 0111 (187)
Character Representation
• ASCII – American Standard Code for
Information Interchange

• 128 characters (7 bits required)


Contains:
• Control characters (non-printing)
• Printing characters (letters, digits,
punctuation)
ASCII – Characters

Hex Equiv. Binary Character

00 00000000 NULL
07 00000111 Bell
09 00001001 Horizontal tab
0A 00001010 Line feed

0D 00001110 Carriage return

20 00100000 Space (blank)


ASCII – Characters

Hex Equiv. Binary Character


30 00110000 0
31 00110001 1
39 00111001 9
41 01000001 A
42 01000010 B
61 01100001 a
62 01100010 b
Error-Detecting Code
• To detect the error in data
communication, an 8th bit is added to
ASCII character to indicate its parity.
• Parity bit - extra bit included with a
message to make the total number of 1’s
either even or odd
• The 8-bit characters included parity bits
(with even parity) are transmitted to their
destination. If the parity of received
character is not even it means at least
one bits has been changed.
Binary Storage and Registers
• Register - group if binary cells that are
responsible for storing and holding the
binary information.

• Register transfer operation is transferring


binary operation from one set of registers
to another set of registers.

• Digital logic circuits process the binary


information stored in the registers.
Exercises
• Perform the following operation using a)
radix complement b) diminished radix
complement
1. 20910-12010 = _____ 10

2. 101001112 – 100011102 = _________2

3. AB1916 – 1EB316 =________ 16

You might also like