Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
71 views75 pages

CA Chapter 1 Number System

Banglore University bca 1st sem sep

Uploaded by

rahulbk182006
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)
71 views75 pages

CA Chapter 1 Number System

Banglore University bca 1st sem sep

Uploaded by

rahulbk182006
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/ 75

NUMBER SYSTEM

What is Number System?

Number System

Number systems are the technique to


represent numbers in the computer
system architecture, every value that you
are saving or getting into/from computer
memory has a defined number system.
• Computer architecture supports
following number systems.
Binary number system
Octal number system
Decimal number system
Hexadecimal (hex) number 3
1
Decimal Number
System

4
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 a positional value system.
◉ This means that the value of digits will depend on its position
◉ Say we have three numbers – 734, 971 and 207. The value of 7 in all three numbers is
different−
◉ In 734, value of 7 is 7 hundreds or 700 or 7 × 100 or 7 × 10 2
◉ In 971, value of 7 is 7 tens or 70 or 7 × 10 or 7 × 10 1
◉ In 207, value 0f 7 is 7 units or 7 or 7 × 1 or 7 × 10 0

5
2
Binary Number
System

6
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, In any binary number, the rightmost digit is
though 0 is not actually no signal but called least significant bit (LSB) and leftmost
signal at a lower voltage.
digit is called most significant bit (MSB).
◉ The number system having just these
two digits – 0 and 1 – is called binary
number system.

7
Octal Number System
3 8
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 Decimal equivalent of any octal number is sum of
with where each digit has its product of each digit with its positional value.
value expressed in powers 7268 = 7×82 + 2×81 + 6×80
of 8
= 448 + 16 + 6
= 47010

9
4
Hexa Decimal
Number System

10
Hexadecimal Number System
◉ Hexa Decimal number
system has 16 symbols – 0
to 9 and A to F where A is
equal to 10, B is equal to 11
and so on till F. Decimal equivalent of any hexadecimal number
◉ Hexadecimal number system is sum of product of each digit with its
is also a positional value positional value.
system with where each
27FB16 = 2×163 + 7×162 + 15×161 + 10×160
digit has its value expressed = 8192 + 1792 + 240 +10
in powers of 16, = 1023410
Here A is 10, B is 11, C is 12, D is 13, E is
14 and F is 15.

11
Binary to Decimal

Binary to The binary number


decimal conversion is system is used in
done to convert a computers and electronic
number given in the systems to represent data
binary number system to and it consists of only
its equivalent value in the two digits which are 0
decimal number system. The binary number and 1.
system has a base of
2 because it has only
two digits to
represent any
number.

12
Binary to Decimal
◉ In any binary number, the rightmost digit is called the 'Least
Significant Bit' (LSB) and the left-most digit is called the 'Most
Significant Bit' (MSB).
◉ For a binary number with 'n' digits, the least significant bit has a
weight of 20 and the most significant bit has a weight of 2n-1.
◉ Step 1: List out the powers of 2 for all the digits starting from the
rightmost position.

13
Binary to Decimal
◉ Step 2: Now multiply each digit in the binary number starting
from the right with its respective weight based on its position
and evaluate the product.

◉ Step 3: Now, express the binary number as a decimal number:


1011012 = 4510

14
Exercises
◉ Convert 11102, from binary to decimal using the binary to
decimal formula.
◉ Convert 11112, from binary to decimal using the binary to
decimal formula.
◉ Convert 10102, from binary to decimal using the binary to
decimal formula.

15
Decimal to Binary
Decimal to Then, the remainders are
binary conversion is done noted down till we get 0
through various methods. as the final quotient.
One of the methods to After this step, these
convert decimal to binary remainders are written in
is by dividing the given reverse order to get the
decimal number binary value of the given
recursively by 2. decimal number.

16
Decimal to binary conversion

◉ To convert numbers from


decimal to binary, the given
decimal number is divided
repeatedly by 2 and the
remainders are noted down
till we get 0 as the final
quotient.

17
Exercises
◉ 25
◉ 39
◉ 72
◉ 55

18
Decimal to Octal

◉ In the number system, each of the types has its own base
number i.e. octal number has a base number of 8 and the
decimal number has a base number of 10.
◉ To convert decimal to octal, we need to divide the decimal
number by the octal base number 8 and write the acquired
remainder in reverse to derive at the equivalent octal number.

19
Convert Decimal to Octal

◉ In this method, the decimal number is divided by 8, each time


a reminder is obtained from the previous digit.
◉ The first remainder obtained is the least significant digit(LSD)
and the last remainder is the most significant digit(MSD).
◉ Once the quotient is less than 8, we obtain the octal number
by writing the remainder in reverse order.

20
Example
◉ Convert the decimal number (85)10 to an octal number.
◉ Step 1: Check if the decimal number is less than 8. If yes, the
octal number is the same. If no, then proceed forward. In this
case, 85 is more than 8 so let's go to step 2.
◉ Step 2: Divide 85 by 8 (octal base number).
◉ Note down the quotient and the remainder in the quotient-
remainder form. Repeat this process (dividing the quotient
again by 8) until we get the quotient to be less than 8.

21
Example

22
Exercises
◉ 67
◉ 99
◉ 350

23
Octal to decimal

24
25
Exercises
◉ (121)8
◉ (454)8

26
Hexadecimal Number System

◉ The base of a hexadecimal system is 16. The 16 symbols


involved in this system include 10 decimal digits and the
first six letters of the English alphabet, i.e. 0, 1, 2, 3, 4, 5, 6,
7, 8, 9, A, B, C, D, E, F. Here, the alphabets can be treated
10, 11, 12, 13, 14 and 15, respectively.

27
Conversion from Hex to Decimal
◉ Convert 7CF (hex) to decimal.
◉ Given hexadecimal number is 7CF.
◉ In hexadecimal system,
◉ 7=7
◉ C = 12
◉ F = 15
◉ To convert this into a decimal number system, multiply each digit with the powers of 16 starting from
units place of the number.
◉ 7CF = (7 × 162) + (12 × 161) + (15 × 160)
◉ = (7 × 256) + (12 × 16) + (15 × 1)
◉ = 1792 + 192 + 15
◉ = 1999

28
◉ Convert (1DA6)16 to decimal.
◉ Convert (E8B)16 to decimal system.
◉ (2bf)16

29
Conversion from Decimal to
Hexadecimal number system

◉ Take decimal number as dividend.


◉ Divide this number by 16 (16 is base of hexadecimal so divisor here).
◉ Store the remainder in an array (it will be: 0 to 15 because of divisor 16,
replace 10, 11, 12, 13, 14, 15 by A, B, C, D, E, F respectively).
◉ Repeat the above two steps until the number is greater than zero.
◉ Print the array in reverse order (which will be equivalent hexadecimal
number of given decimal number).

30
Convert 60010 into a hexadecimal number.

31
Binary to octal Conversion

32
Octal to Binary Conversion

33
Hexa Decimal to Binary
Conversion

34
Binary to Hexa Decimal Number
(1000101)2
Start from the right and divide into 4 Blocks
0100 0101

35
Octal to Hexa Decimal Number
◉ Step1: Convert Octal to Binary
◉ Group 4 bits together and represent equivalent hexa
decimal digit

36
Hexa decimal to Octal
conversion
◉ Step1: Convert Hexa decimal to binary
◉ Step2: Regrouping the bits into 3 bits

37
Complements
◉ complement number system An alternative representation
of numbers in a fixed-radix number system
◉ Complements are used in the digital computer in order to
simplify the subtraction operation and for logical
manipulation.
◉ For Each Radix system( Radix r represents the number
system)
◉ There are 2 types of Complements(r, r-1) complements
◉ r-radix complement,r-1=Diminished radix complement.

38
Binary system Complements
◉ There are 2 complements in Binary System
1. 1’s Complement
2. 2’s complement

39
1’s Complement
◉ To generate a 1’s complement for any given binary number,
you only need to invert that number.
◉ For a binary number like 110010, the 1’s complement
would be 001101.

40
2’s complement
◉ To generate a 2’s complement for any given binary number,
you need to invert it. Then you need to add 1 to the LSB (Least
Significant Bit) of the generated result.
◉ 1’s complement + 1

41
Positive and Negative Numbers
◉ In Digital system it is not possible to use negative sign(-)
before them.
◉ Binary system has extra bit called signed bit to represent the
sign of a number
◉ if the sign bit is '1', the number is negative; if the sign bit is '0',
the number is positive.
◉ In negative number remain bits will be represented as Signed
magnitude method(1’s or 2’s complement)

42
Signed Magnitude Method
◉ The sign-magnitude binary format is the simplest conceptual format. In
this method of representing signed numbers, the most significant digit
(MSD) takes on extra meaning.
◉ If the MSD is a 0, we can evaluate the number just as we would any
normal unsigned integer. And also we shall treat the number as a
positive one.
◉ If the MSD is a 1, this indicates that the number is negative.

43
Signed Magnitude 1’s
Complement

44
2’s complement Method
◉ +5 is represented as it is represented in sign magnitude method.
-5 is represented using the following steps:
◉ (i) +5 = 0 0101
◉ (ii) Take 2’s complement of 0 0101 and that is 1 1011. MSB is 1
which indicates that number is negative.
◉ MSB is always 1 in case of negative numbers.

45
Binary Arithmetic
◉ Binary Arithmetic includes the basic operation like
1. Binary addition
2. Binary Subtraction
3. Binary multiplication
4. Binary Division.

46
Binary Addition
◉ The addition of 2 Binary numbers is performed exactly
same as the decimal number addition.

47
Addition using 2’s complement
◉ The 2’s complement is most commonly used code for
processing positive and negative binary numbers. There
are 4 different cases
1. Both the numbers are positive
2. Larger of 2 numbers are positive
3. The larger of 2 numbers are negative
4. Both the numbers are negative

48
◉ Case 2: Larger of 2 numbers are positive
Example: 1101 and -1001
◉ First, find the 2's complement of the negative number 1001. So, for finding
2's complement, change all 0 to 1 and all 1 to 0 or find the 1's complement
of the number 1001. The 1's complement of the number 1001 is 0110, and
add 1 to the LSB of the result 0110. So the 2's complement of number 1001
is 0110+1=0111
◉ Add both the numbers, i.e., 1101 and 0111;
1101+0111=1 0100
◉ By adding both numbers, we get the end-around carry 1. We discard the
end-around carry. So, the addition of both numbers is 0100.

49
Case 3: The larger of 2 numbers are negative
Example: 1101 and -1110
◉ First, find the 2's complement of the negative number 1110. So, for
finding 2's complement, add 1 to the LSB of its 1's complement value
0001.
0001+1=0010
◉ Add both the numbers, i.e., 1101 and 0010;
1101+0010= 1111
◉ Find the 2's complement of the result 1110 that is the final result. So, the
2's complement of the result 1110 is 0001, and add a negative sign
before the number so that we can identify that it is a negative number.

50
Case 4: Both the numbers are negative
Example: -1101 and -1110 in five-bit register
◉ Firstly find the 2's complement of the negative numbers 01101 and
01110. So, for finding 2's complement, we add 1 to the LSB of the 1's
complement of these numbers. 2's complement of the number 01110 is
10010, and 01101 is 10011.
◉ We add both the complement numbers, i.e., 10001 and 10010;
10010+10011= 1 00101
◉ By adding both numbers, we get the end-around carry 1. This carry is
discarded and the final result is the 2.s complement of the result 00101.
So, the 2's complement of the result 00101 is 11011, and we add a
negative sign before the number so that we can identify that it is a
negative number.

51
Binary Subtraction
◉ Binary subtraction is one of the four binary operations, where
we perform the subtraction method for two binary numbers
(comprising only two digits, 0 and 1).
◉ This operation is similar to the basic arithmetic subtraction
performed on decimal numbers in Maths.
◉ Binary Subtraction
◉ 0–0=0
◉ 1–0=1
◉ 1–1=0
◉ 0 – 1 = 1 (Borrow 1)

52
Case i) Binary subtraction without borrowing
Case ii) Binary subtraction with borrowing
Case iii)Binary Subtraction Using 1's Complement

Case i) Binary subtraction without borrowing


Subtract 100 from 1111 .Here number 4 is represented in binary
as 100 and number 15 is represented as 1111.

53
Case ii) Binary subtraction with borrowing:

54
Case iii)Binary Subtraction Using 1's Complement

55
Binary Subtraction Using 2's
Complement
◉ Step 1: Determine the 2’s complement of the smaller number
◉ Step 2: Add this to the larger number.
◉ Step 3: Omit the carry. Note that there is always a carry in this case.

56
Binary Multiplication
◉ The binary multiplication is very much similar to the usual multiplication
method of integers.
◉ First, we need to multiply each digit of one binary number to each digit
of another binary number.

57
Binary Division
◉ The binary division operation is similar to
the base 10 decimal system, except the base 2.
◉ The division is probably one of the most
challenging operations of the basic arithmetic operations.
◉ Solve 01111100 ÷ 0010

58
Codes in Digital Electronics
◉ The digital data is represented, stored and transmitted as group of
bits. This group of bits is also called as binary code.
Binary codes can be classified into two types.
◉ Numeric codes
◉ Alpha Numeric codes
Alpha Numeric Codes are classified into 4 Groups
1. Weighted Codes
2. Non weighted codes
3. Alpha Numeric codes
4. Error detecting and correction codes

59
◉ BCD ( Binary Coded Decimal):
Binary Coded Decimal, or BCD, is another process for converting decimal
numbers into their binary equivalents.
◉ It is a form of binary encoding where each digit in a decimal number is
represented in the form of bits.
◉ This encoding can be done in either 4-bit or 8-bit (usually 4-bit is
preferred).
◉ It is a fast and efficient system that converts the decimal numbers into
binary numbers as compared to the existing binary system.
◉ The BCD code is more precisely known as 8421 BCD code , with 8,4,2
and 1 representing the weights of different bits in the four-bit groups

60
Example

61
Excess-3 Code
◉ The excess-3 code (or XS3) is a non-weighted code used to
express code used to express decimal numbers.
◉ It is a self-complementary binary coded decimal (BCD) code
and numerical system which has biased representation
An Excess-3 equivalent of a given binary number is obtained using
the following steps:
◉ Find the decimal equivalent of the given binary number.
◉ Add +3 to each digit of decimal number.
◉ Convert the newly obtained decimal number back to binary
number to get required excess-3 equivalent.

62
63
Gray Code
◉ A Gray code is an encoding of numbers so that adjacent
numbers have a single digit differing by 1.
◉ The Gray Code is a sequence of binary number systems,
which is also known as reflected binary code.
◉ Gray codes are used in the general sequence of hardware-
generated binary numbers
◉ The gray code is a very light weighted code because it
doesn't depend on the value of the digit specified by the
position.

64
How to generate Gray code?
For generating gray code:
◉ We find the number of bits required to represent a number.
◉ Next, we find the code for 0, i.e., 0000, which is the same as
binary.
◉ Now, we take the previous code, i.e., 0000, and change the most
significant bit of it.
◉ We perform this process reclusively until all the codes are not
uniquely identified.
◉ If by changing the most significant bit, we find the same code
obtained previously, then the second most significant bit will be
changed, and so on.

65
66
Binary code to Gray code

67
Conversion from Gray code to
Binary Code

68
Alphanumeric Code
◉ Alphanumeric codes (also known as character codes) are
defined as binary codes used to represent alphanumeric data.
◉ The codes write alphanumeric data, including letters of the
alphabet, mathematical symbols, numbers, and punctuation
marks, in a form that is easily understood by a computer.
◉ The most common alphanumeric codes used these days are
ASCII code,
EBCDIC code,
UNICODE.

69
ASCII Code
◉ The full form of ASCII code is the American Standard Code for
Information Interchange.
◉ It is a seven-bit code based on the English alphabet
◉ it can almost represent 128 characters. These include 95
printable characters including 26 upper-case letters (A to Z),
26 lowercase letters (a to z), 10 numerals (0 to 9) and 33
special characters such as mathematical symbols, space
character etc.

70
EBCDIC(Extended Binary Coded
Decimal Interchange Code)
◉ This is a coding system used to represent characters-letters,
numerals, punctuation marks, and other symbols in
computerized text.
◉ A character is represented in EBCDIC by eight bit. EBCDIC
mainly used on IBM mainframe and IBM midrange computer
operating systems.
◉ Each byte consists of two nibbles, each four bits wide.
◉ The first four bits define the class of character, while the
second nibble defines the specific character inside that class

71
EBCDIC

72
Representation
◉ In computers, fixed-point representation is a real data type for
numbers.
◉ Fixed point representation can convert data into binary form,
and then the data is processed, stored, and used by the
computer.
◉ It has a fixed number of bits for the integral and fractional parts.

73
◉ Sign bit:- The fixed-point number representation in binary uses a sign bit.
The negative number has a sign bit 1, while a positive number has a bit
0.
◉ Integral Part:- The integral part in fixed-point numbers is of different
lengths at different places. It depends on the register's size; for an 8-bit
register, the integral part is 4 bits.
◉ Fractional part:- The Fractional part is of different lengths at different
places. It depends on the registers; for an 8-bit register, the fractional
part is 3 bits.

74
How to write numbers in
Fixed-point notation

75

You might also like