computer fundamentals lecture 02 sri lanka institute of information technology (sliit)
DESCRIPTION
Computer Fundamentals Lecture 02 Sri Lanka Institute of Information Technology (SLIIT)TRANSCRIPT
04/08/23 Sri Lanka Institute of Information Technology
1
Computer Fundamentals
Lecture 2: Number Systems
04/08/23 Sri Lanka Institute of Information Technology
2
Objectives After completing this lecture you will
be able to: Explain different positionally-waited
number systems Translate numbers between number
systems Appraise binary number system
04/08/23 Sri Lanka Institute of Information Technology
3
Agenda Number bases used with computers Why binary? Number Base Conversion Conversion of Fractions
04/08/23 Sri Lanka Institute of Information Technology
4
Number bases used with computers
Decimal, b=10a={0,1,2,3,4,5,6,7,8,9}
Binary, b=2a={0,1}
Octal, b=8a={0,1,2,3,4,5,6,7}
Hexadecimal, b=16a={0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F}
04/08/23 Sri Lanka Institute of Information Technology
5
Why Binary is used in Computers? Electronic components that represent
binary are better than those that represent binary because of; Easier to design Cost effective
04/08/23 Sri Lanka Institute of Information Technology
6
Number Base ConversionDecimal to Binary divide the number successively by 2, and after each
division record the remainder which is either 1 or 0. example,
12310 becomes 123/2 =61 r=161/2 = 30 r=130/2 = 15 r=015/2 = 7 r=17/2 =3 r=13/2 =1 r=11/2 =0 r=1
12310 = 11110112
04/08/23 Sri Lanka Institute of Information Technology
7
Decimal to Octal Divide the number by 8 remainder is a number in the range 0 to 7.
example, 462910 becomes
4629/8= 578 r=5578/8= 72 r=272/8= 9 r=09/8 = 1 r=11/8 = 0 r=1
462910 =110258
Number Base Conversion
04/08/23 Sri Lanka Institute of Information Technology
8
Decimal to Hexadecimal Divide the number by 16 remainder lies in the decimal range 0 to 15, corresponding to the
hexadecimal range 0 to F. example, 5324110 becomes
53241/16 = 3327 r=93327/16 = 207 r=15 = F207/16 =12 r=15 = F12/16 =0 r=12 = C
5324110=CFF916
Number Base Conversion
04/08/23 Sri Lanka Institute of Information Technology
9
Binary to Decimal Take the left most none zero bit, double it and add it to the bit on its right. Now take this result, double it and add it to the next bit on
the right. Continue in this way until the least significant bit has been
added in.
Number Base Conversion
04/08/23 Sri Lanka Institute of Information Technology
10
Binary to Decimal (cont’d)
For example, 10101112 becomes
Therefore, 10101112 = 8710
Number Base Conversion
04/08/23 Sri Lanka Institute of Information Technology
11
Binary to Octal Form the bits into groups of three starting at the
binary point and moving leftwards. Replace each group of three bits with the
corresponding octal digit (0 to 7).For example,110010111012 becomes 11 001 011 101
3 1 3 5
Therefore,110010111012 = 31358
Number Base Conversion
04/08/23 Sri Lanka Institute of Information Technology
12
Binary to Hexadecimal The binary number is formed into groups of four bits
starting at the decimal point. Each group is replaced by a hexadecimal digit from 0 to
9, A, B, C, D, E, and F.For example,
110010111012 becomes 110 01011101
6 5 D
Therefore, 110010111012 = 65D16
Number Base Conversion
04/08/23 Sri Lanka Institute of Information Technology
13
Octal to Binary Each octal digit is simply replaced by its 3-bit binary equivalent. It is important to remember that (say) 3 must be replaced by 011
and not 11.For example,413578 becomes 4 1 3 5 7
100 001 011 101 111
Therefore,413578 = 1000010111011112.
Number Base Conversion
04/08/23 Sri Lanka Institute of Information Technology
14
Hexadecimal to Binary Each hexadecimal digit is replaced by its 4-bit binary equivalent. For example AB4C16 becomes A B 4 C
1010 1011 0100 1100
Therefore, AB4C16 = 10101011010011002
Number Base Conversion
04/08/23 Sri Lanka Institute of Information Technology
15
Octal to Decimal Take the left-most digit, Multiply it by eight and add it to the digit on its right. Then, multiply this subtotal by eight and add it to the next
digit on its right. The process ends when the left-most digit has been added to
the subtotal.For example, 64378 becomes 6 4 3 7
4852
416419
33523359
Therefore, 64378 = 335910
Number Base Conversion
04/08/23 Sri Lanka Institute of Information Technology
16
Hexadecimal to Decimal The method is identical to the procedures for binary and
octal except that 16 is used as a multiplier.
For example, 1AC16 becomes 1 A C
1626
416428
Therefore, 1AC16 = 42810
Number Base Conversion
04/08/23 Sri Lanka Institute of Information Technology
17
Conversion of FractionsConverting Binary Fractions to Decimal Fractions For example, consider the conversion of 0.011012 into decimal
form.0.0 0 1 1 0 1
1/21/2
1/45/4
5/813/8
13/1613/16
13/32Therefore, 0.011012 = 13/32.
04/08/23 Sri Lanka Institute of Information Technology
18
Converting Decimal Fractions to Binary Fractions For example, 0.687510 becomes 0.6875 x 2 1.3750
0.3750 x 2 0.75000.7500 x 2 1.50000.5000 x 2 1.0000
0.0000 x 2 ends the processTherefore, 0.687510 = 0.10112
Conversion of Fractions
04/08/23 Sri Lanka Institute of Information Technology
19
Thank YouLecture 03: Computer Arithmetic