CH 2
CH 2
Chapter-2
Number Systems and Codes
1
Number Systems and Codes
1. Decimal number system: The decimal number system, also known as the
base-10 system, is the most commonly used number system in everyday life.
It uses 10 digits (0-9) to represent numbers.
Cont’d…
1.3 Binary number system: The binary number system uses only two digits
(0 and 1) to represent numbers. It is widely used in digital electronics
and computer programming.
2. Octal number system: The octal number system uses eight digits (0-7)
to represent numbers. It is commonly used in computer
programming and in some types of telecommunications.
= (1111)2 à 4 digits
= (F) à 1 digits
Cont’d…
6 Decimal number system, symbols = { 0, 1, 2, 3, …, 9 }
Position is important
o Example: (7594)10 = (7x103) + (5x102) + (9x101) +
(4x100).
The value of each symbol is dependent on its type and its
position in the number.
Fractions are written in decimal numbers after the
decimal point.
(2.75)10 = (2 x 100) + (7 x 10-1) + (5 x 10-2)
1.Number And Base Conversion
7 Conversion from decimal to another base (Base 10 Base M)
•To convert a decimal number X to a number in base M, divide X by M, find the remainder, again
divide the result by M, find the remainder, continue until the result is 0. Finally concatenate (collect)
the remainders starting from the last up to the first.
Ex.1 Convert 5610 to base 2 (binary)
X=56, M=2
5610 =1110002
7810=1168
3010=1E16
16010=A016
Conversion from base M to base 10 (decimal)
8 To convert a number X consists of digits X1 X2 X3 …Xn in base M to decimal; simply
expand the number with base M. That is (X1X2X3…Xn) m =X1*mn-1+X2*mn-2
+X3*mn-3+ …. + XI*mn-i+… Xn-1*m1+Xn*m0 = Y10
Examples:
1001001=001,001,001
= 1118
=5518
Cont’d…
10 To convert binary to hexadecimal group four binary digits together starting from right and if there are
no enough digits add zeros at the left.
To convert from Octal to binary, convert each octal digit to its equivalent 3 bit binary starting from
right.
=100110012
Cont’d…
11 Toconvert from Hexadecimal to binary convert each hex digit to its
equivalent 4-bit binary, starting from right.
= 10001101002
=10101011002
Conversion from Octal to hexadecimal and vice versa
12 To convert from Octal to hexadecimal, first we have to convert to binary and the binary to
hexadecimal.
To convert from hexadecimal to Octal, first we have to convert to binary and then the binary
to Octal.
EX.1. Convert 2358 to hexadecimal Convert 1A to Octal
In a 5- bit representation, we use the first bit for sign and the remaining 4- bits for the magnitude.
So, using this 5-bit representation the range of numbers that can be represented is from -15 (01111) to 15(11111)
In other words, the binary addition of signed numbers does not “Work Correctly”.
The solution to this problem is called the two’s complement representation.
One’s complement
16 In one’s complement representation, all positive integers are represented in their correct binary format.
For example +3 are represented as usual by 00000011. However, its complement, -3, is obtained by
complementing every bit in the original representation.
Each 0 is transformed into a1 and each 1 into a0. In our example, the one’s complement representation of -3 is
11111100.
Note that in this representation positive numbers start with a 0 on the left, and negative numbers start with a 1 on
the left.
- 4 is 11111011
+ 6 is 00000110
-3+-2
-3 is 11111100
-2 is 11111101
11111001or -6 plus a carry
The correct result is -5. The representation of –5 is 11111010.
This representation does represent positive and negative numbers: however, the
result of an ordinary addition does not always come out correctly
It is evolved from the one’s complement and is called the two’s complement
representation.
Two’s Complement Representation
18 A negative number represented in two’s complement is obtained by first computing the one’s complement and
then adding one.
It is 11111101.
(3) 00000011
+ (5) + 00000101
(8) 0001000
arrangements of bits.
There are different coding systems that convert one or more character sets into
computer codes, some are: -BCD (Binary Coded Decimal),
ASCII (American Standard Code for Information Interchange),
With BCD, each digit of a number is converted into its binary equivalent rather than converting
the entire decimal number to its binary form.
Example: The BCD value of the decimal number 5319 is 0101 0011 0001 1001
Converting decimal number to BCD equivalence
To convert a decimal number to its equivalent BCD simply convert each decimal digit to its 4bit binary and combine the groups
together
=10000110010BCD
To convert BCD to decimal group into four & find its corresponding decimal.
ASCII Code
22
ASCII (American Standard Code for Information Interchange) is a character
encoding standard that assigns unique numeric codes to represent characters in
the English alphabet, as well as punctuation marks, digits, and other symbols
commonly used in computing.
Originally developed for teletype machines in the 1960s, ASCII uses 7-bit binary
numbers (i.e., sequences of 0s and 1s) to represent a total of 128 different characters,
including uppercase and lowercase letters, digits, punctuation marks, and control
codes for basic formatting and communication.
For example, the ASCII code for the letter "A" is 65, the code for the
digit "0" is 48, and the code for the space character is 32.
EBCDIC (Extended Binary Coded Decimal Interchange Code)
23
EBCDIC (Extended Binary Coded Decimal Interchange Code) is another character
encoding standard that was developed by IBM in the 1960s. Like ASCII, EBCDIC
assigns unique numeric codes to represent characters in the English alphabet, as well
as punctuation marks, digits, and other symbols commonly used in computing.
However, EBCDIC uses an 8-bit binary code to represent a total of 256 different
characters, which is more than twice the number of characters that can be
represented in ASCII.
EBCDIC was used extensively on IBM mainframe computers and some other
systems, particularly in the banking and finance industries.
Unicode
24
Unicode is a character encoding standard that was introduced in the 1990s as a way
to represent characters from all the world's writing systems using a single character
set.
You
h a n k
T A
Q &