Module 1: Computer Fundamentals
1.1 Introduction to Number System and codes
Number Systems: Binary, Octal,
Decimal and Hexadecimal
Number System:
A number system is a way to represent numbers. We
have used base-10 number system, which is also
called decimal.
Other common number systems include :
base-16 (hexadecimal), base-8 (octal), and base-2
(binary).
Decimal number system:
• Decimal number system is a base 10 number system having 10
digits from 0 to 9.
• This means that any numerical quantity can be represented using
these 10 digits.
• Decimal number system is also called as positional value system.
• This means that the value of digits will depend on its position.
Binary number system:
The easiest way to vary instructions through electric
signals is two-state system on and off.
On is represented as 1 and off as 0, though 0 is not
actually no signal but signal at a lower voltage.
The number system having just these two digits 0 and
1 is called binary number system.
Each binary digit is also called a bit. Binary number
system is also positional value system, where each
digit has a value expressed in powers of 2.
• In any binary number, the rightmost digit is
called Least significant bit (LSB) and leftmost digit
is called Most significant bit (MSB).
Octal Number System:
Octal number system has eight digits 0, 1, 2, 3, 4, 5,
6 and 7. Octal number system is also a positional value
system with where each digit has its value expressed in
powers of 8, as shown here
Remember how in base-10 we had ten digits? Now, in
base 8, we are limited to only eight digits: 0, 1, 2, 3, 4,
5, 6, and 7. There’s no such thing as 8 or 9.
Hexadecimal Number System:
Hexadecimal number system is also a positional value
system with where each digit has its value expressed in
powers of 16, as shown here
Decimal Number System
Numbers consist of a bunch of digits, each with a weight
1 6 2 . 3 7 5 Digits
100 10 1 1/10 1/100 1/1000 weight
These weights are all powers of the base, which is 10. We can
rewrite this:
1 6 2 . 3 7 5 Digits
102 101 100 10-1 10-2 10-3 weight
To find the decimal value of a number, multiply each digit by
its weight and sum the products.
(1 x 102) + (6 x 101) + (2 x 100) + (3 x 10-1) + (7 x 10-2) + (5 x 10-3) = (162.375) 10
Decimal Number System
Base (also called radix) = 10
10 digits { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }
Digit Position
2 1 0 -1 -2
Integer & fraction
Digit Weight
5 1 2 7 4
Weight = (Base) Position
100 10 1 0.1 0.01
Magnitude 500 10 2 0.7 0.04
Sum of “Digit x Weight”
Formal Notation
d2*B2+d1*B1+d0*B0+d-1*B-1+d-2*B-2
(512.74)10
NUMBER CONVERSIONS
Binary to Decimal
Octal to Decimal
Hexadecimal to Decimal
Binary to Decimal Number System
Base = 2
2 digits { 0, 1 }, called binary digits or “bits”
Weights 4 2 1 1/2 1/4
Weight = (Base) Position 1 0 1 0 1
Magnitude 2 1 0 -1 -2
Sum of “Digit x Weight”
1 *22+0 *21+1 *20+0 *2-1+1 *2-2
Formal Notation
=(5.25)10
Groups of bits
(101.01)2
4 bits = Nibble 1 0 1 1
8 bits = Byte 11000101
EXAMPLE:
Convert the binary number in to decimal number
1) 010112
2) 0101111002
Octal to Decimal Number System
Base = 8
8 digits { 0, 1, 2, 3, 4, 5, 6, 7 }
Weights
64 8 1 1/8 1/64
Weight = (Base) Position
5 1 2 7 4
Magnitude
Sum of “Digit x Weight” 2 1 0 -1 -2
Formal Notation 5 *82+1 *81+2 *80+7 *8-1+4 *8-2
=(330.9375)10
(512.74)8
EXAMPLE
Convert the Octal number in to Decimal number
1) 178
2) 532.28
Hexadecimal to Decimal Number System
Base = 16
16 digits { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F }
Weights
256 16 1 1/16 1/256
Weight = (Base) Position
1 E 5 7 A
Magnitude
Sum of “Digit x Weight” 2 1 0 -1 -2
Formal Notation 1 *162+14 *161+5 *160+7 *16-1+10 *16-2
=(485.4765625)10
(1E5.7A)16
EXAMPLE
Convert the hexadecimal number to Decimal
1) 6DE 16
2) 1E.5316
Number Base Conversions
Evaluate
Magnitude
Octal
(Base 8)
Evaluate
Magnitude
Decimal Binary
(Base 10) (Base 2)
Hexadecimal
(Base 16)
Evaluate
Magnitude
Link for MCQ:
https://forms.office.com/Pages/ResponsePage.aspx?
id=ACxf6DAnpUy42GCbFb1HRtznbjjqgR1Lvg0-
Z8ZyXBlUQ1VTR1pBRzRUSkczV09ENkpUTkZGSFlEVC4u
Binary
Binary representation:
The Power of 2
n 2n n 2n
0 20=1 8 28=256
1 21=2 9 29=512
2 22=4 10 210=1024 Kilo
3 23=8 11 211=2048
4 24=16 12 212=4096
5 25=32 20 220=1M Mega
6 26=64 30 230=1G Giga
7 27=128 40 240=1T Tera
Convert binary to decimal:
Example 1: 10011101 to decimal ?
multiply each digit by its weight and sum the products.
Digital design book page 21
1 0 0 1 1 1 0 1
1*27 + 0*26 + 0*25 + 1*24 + 1*23 + 1*22 + 0*21 + 1*20
1* 128 + 0*64 + 0*32 + 1*16 + 1*8 + 1*4 + 0* 2 + 1* 1
128 + 16 + 8 + 4 +1
(157) 10
Binary to Decimal :
Example 2 :Convert the binary 1101.01 to decimal.
1 1 0 1 . 0 1 Binary digits, or bits
23 22 21 20 2-1 2-2 Weights (in base 2)
The decimal value is:
(1 x 23) + (1 x 22) + (0 x 21) + (1 x 20) + (0 x 2-1) + (1 x 2-2) =
8 + 4 + 0 + 1 + 0 + 0.25 = (13.25) 10
CONVERSION OF BINARY TO
DECIMAL:
CONVERSION OF OCTAL TO DECIMAL:
CONVERSION OF OCTAL TO
DECIMAL:
CONVERSION OF HEXADECIMAL TO
DECIMAL:
CONVERSION OF HEXADECIMAL TO
DECIMAL:
Convert from decimal to binary:
To convert a decimal integer into binary, keep dividing by 2 until the quotient
is 0. Collect the remainders in reverse order.
To convert a fraction, keep multiplying the fractional part by 2 until it becomes
0 or endless pattern. Collect the integer parts in forward order.
Example 1: 162.375
162 / 2 = 81 rem 0 0.375 x 2 = 0.750
81 / 2 = 40 rem 1 0.750 x 2 = 1.500
40 / 2 = 20 rem 0 0.500 x 2 = 1.000
20 / 2 = 10 rem 0
10 / 2 =5 rem 0
5/2 =2 rem 1
2/2 =1 rem 0
1/2 =0 rem 1
So, 162.37510 = 10100010.0112
Convert from decimal to binary:
Example :
(746) 10 =(1011101010)
2
Convert from decimal to binary:
Endless Pattern Example
(21.1) 10 =(10101.00011)2
CONVERT FROM DECIMAL TO HEXADECIMAL:
Example :
Convert from decimal to hex
764= ?
(764) 10 = (2EA) 16
CONVERT FROM DECIMAL TO
HEXADECIMAL:
Decimal to Octal Conversion:
Example: (175)10
Quotient Remainder Coefficient
175 / 8 = 21 7 a0 = 7
21 / 8 = 2 5 a1 = 5
2 /8= 0 2 a2 = 2
Answer: (175)10 = (a2 a1 a0)8 = (257)8
Example: (0.3125)10
Integer Fraction Coefficient
0.3125 * 8 = 2 . 5 a-1 = 2
0.5 *8= 4 . 0 a-2 = 4
Answer: (0.3125)10 = (0.a-1 a-2 a-3)8 = (0.24)8
convert hexadecimal to binary:
Replace each hex digit with its equivalent 4-bit binary sequence.
261.3516 = 2 6 1 . 3 516
= 0010 0110 0001 . 0011 01012
CONVERT BINARY TO HEXADECIMAL:
To convert from binary to hex, make groups of 4 bits, starting from the
binary point. Add 0s to the ends of the number if needed. Then, just convert
each bit group to its corresponding hex digit.
10110100.0010112 = 1011 0100 . 0010 11002
= B 4 . 2 C16
Hex Binary Hex Binary Hex Binary Hex Binary
0 0000 4 0100 8 1000 C 1100
1 0001 5 0101 9 1001 D 1101
2 0010 6 0110 A 1010 E 1110
3 0011 7 0111 B 1011 F 1111
Binary − Octal Conversion Octal Binary
8 = 23
Each group of 3 bits represents an 0 000
octal digit 1 001
2 010
Assume Zeros
Example: 3 011
( 1 0 1 1 0 . 0 1 )2 4 100
5 101
6 110
( 2 6 . 2 )8 7 111
Works both ways (Binary to Octal & Octal to Binary)
Octal − Hexadecimal Conversion:
Convert to Binary as an intermediate step
Example:
( 2 6 . 2 )8
Assume Zeros Assume Zeros
( 0 1 0 1 1 0 . 0 1 0 )2
(1 6 . 4 )16
Works both ways (Octal to Hex & Hex to Octal)
Hexadecimal to Octal Conversion:
Number Base Conversions
Evaluate
Magnitude
Octal
(Base 8)
Evaluate
Magnitude
Decimal Binary
(Base 10) (Base 2)
Hexadecimal
(Base 16)
Evaluate
Magnitude
https://forms.office.com/Pages/ResponsePage.aspx?
id=ACxf6DAnpUy42GCbFb1HRtznbjjqgR1Lvg0-
Z8ZyXBlUQjNETUdFSkFUVVRNQVlSVzZZR0xaNTU2WS4u