LEC02 - Computer Arithmetic (Bin, Dec)
LEC02 - Computer Arithmetic (Bin, Dec)
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