0% found this document useful (0 votes)
22 views12 pages

LEC02 - Computer Arithmetic (Bin, Dec)

The document discusses computer arithmetic, including integer and floating point representations. It covers the arithmetic logic unit, integer representations like sign-magnitude and binary, and algorithms for converting between binary and decimal and performing arithmetic operations like addition, subtraction, and multiplication on binary numbers.

Uploaded by

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

LEC02 - Computer Arithmetic (Bin, Dec)

The document discusses computer arithmetic, including integer and floating point representations. It covers the arithmetic logic unit, integer representations like sign-magnitude and binary, and algorithms for converting between binary and decimal and performing arithmetic operations like addition, subtraction, and multiplication on binary numbers.

Uploaded by

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

Computer Arithmetic

Computer Arithmetic
 Commonly performed on two very different types of
numbers, integer and floating point.
Arithmetic & Logic Unit (ALU)
 Part of the computer that actually performs arithmetic and
logical operations on data
Integer Representation
 With the help of two symbols, the minus sign and the
period, arbitrary numbers can be represented. For example,
-1011.0101
2
= 11.3125 10
 For purposes of computer storage and processing, however,
we do not have the benefit of minus signs and periods.
Only binary digits may be used to represent numbers.
00000000 = 0
00000001 = 1
10000000 = 128
11111111 = 255
Sign-Magnitude
 Left most bit is sign bit
0 means positive
1 means negative
00010010 = +18
10010010= -18
Binary to Decimal
The digits 0, 1, … 9 are to write any number in the decimal system.
Likewise, we use 0 and 1 to write numbers in the binary number system.
In decimal number system which is also called the base-10 system , the
decimal number 149 is written as follows:
149 = 1*102 + 4*101 + 9*100
The binary or base-2 number 1 0 0 1 0 1 0 1 can be converted to a decimal
number as follows:
1*27 + 0*26 + 0*25 + 1*24 + 0*23 + 1*22 + 0*21 + 1*20
= 128 + 16 + 4 + 1
= 149

The binary number 1 0 0 1 0 1 0 1 is written as 149 in the decimal system.


Decimal to Binary
Convert the decimal number 123 to a binary number. 

123 ÷ 2 = 61 , remainder = 1 , least significant bit, goes to the


right. 
61 ÷ 2 = 30 , remainder = 1 
30 ÷ 2 = 15 , remainder = 0 
15 ÷ 2 = 7 , remainder = 1 
7 ÷ 2 = 3 , remainder = 1 
3 ÷ 2 = 1 , remainder = 1 
1 ÷ 2 = 0 , remainder = 1 , Most significant bit, goes to the left. 

The decimal number 123 in written as 1 1 1 1 0 1 1 in binary.


1’s Complement
 To perform 1’s complement operation on a set of binary
digits, simply replace 0 digits with 1, and 1 digits with 0
X = 01010001
1’s complement of X = 10101110
Y = 10101110
1’s complement of Y = 01010001
2’s Complement
 Steps:
 Perform 1’s complement operation
 Treat the result as unsigned binary integer, add 1
18 = 00010010
1’s complement = 11101101
+1
-18 = 2’s complement of 18 = 11101110
Integer Arithmetic
 Addition
 With a complement notation, it is possible to treat the
numbers as unsigned integers for purposes of addition and
subtraction.
0001= 1
+0110 = 6
0111= 7
Subtraction
 Subtraction and Borrow, these two words will be
used very frequently for the binary subtraction. There
are four rules of binary subtraction.
 M = 5 = 0101
S = 2 = 0010
0011 = 3
Multiplication
 Compared to addition and subtraction, multiplication is a
complex operation, whether performed in hardware or
software

1011 Multiplicand (11)


x 1101 Multiplier (13)
1011 Partial products
0000
1011
1011
10001111 Product (143)

You might also like