0% found this document useful (0 votes)
26 views34 pages

Chapter 3

Chapter 3 discusses data representation and computer arithmetic, covering fundamental units such as bits, bytes, and various number systems including decimal, binary, octal, and hexadecimal. It explains methods for converting between these systems and details binary arithmetic operations. Additionally, it addresses computer coding methods and representations of negative numbers.
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)
26 views34 pages

Chapter 3

Chapter 3 discusses data representation and computer arithmetic, covering fundamental units such as bits, bytes, and various number systems including decimal, binary, octal, and hexadecimal. It explains methods for converting between these systems and details binary arithmetic operations. Additionally, it addresses computer coding methods and representations of negative numbers.
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/ 34

01000011 01101000 01100001 01101100 01100001 00100000 01010011 01101001 01101101 01101111 01101110 00100000 01000110 01101001 01101011

01100001 01100100 01110101

01101111 01101110 00100000 01000110 01101001 01101011 01100001 01100100 01110101


01000011 01101000 01100001 01101100 01100001 00100000 01010011 01101001 01101101
01000011 01101000 01100001 01101100 01100001 00100000 01010011 01101001 01101101
01101111 01101110 00100000 01000110 01101001 01101011 01100001 01100100 01110101

Chapter 3: Data Representation and Computer Arithmetic

By: Behayilu M.

01000011 01101000 01100001 01101100 01100001 00100000 01010011 01101001 01101101 01101111 01101110 00100000 01000110 01101001 01101011 01100001 01100100 01110101
Chapter Three: Data Representation and Computer Arithmetic

• Units of Data Representation

1. BIT:

• Bits are the smallest units of data representation and can convey only two possible states 0 or 1;

• Bit stands for Binary digits;

2. BYTE:
• the basic “unit of data representation” in a computer system.

• It contains 8 bits.

3. Word:
• the number of bits that a computer process at a time or a transmission media transmits at a time.

• Formed by combination of bytes

4. Nibble:
• Group of 4 continuous bits
…cont’d

• A byte is then used as a unit of measurement in the computer memory, processing unit, external storage and
during communication.
• Bit
• Nibble
• Byte
• Kilo Byte
1 KB = 210 ≈ 1,024 Bytes
• Mega Byte
1 MB = 210 ≈ 1024KB = 1,048,576 Bytes
• Giga Byte
1 GB = 210 ≈ 1024MB = 1,048,576 KB = 1,073,741,824 Bytes
• Tera Byte
1 TB = 210 ≈ 1024 GB = 1,048,576
• Peta Byte
MB = 8,388,608 KB = 1,099,511,627,776 Bytes
• EXA Byte
• Zetta Byte
• Yotta Byte
Concept of Number Systems and Binary Arithmetic

• A number system defines a set of values used to represent quantity.

• Any number is made up of individual digits.

• For example the number 803 consists of 3 digits: 8, 0 and 3.

• The value of each digit depends on three things:

• The digit itself

• The position of the digit in the number

• The base of the number

• The number systems that are generally used by computers are: decimal, binary, octal, and
hexadecimal.
… Number System

• 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.

• Binary Number System:


• The number system having just these two digits – 0 and 1 – is called binary number system.
• Binary number system is also positional value system, where each digit has a value expressed in powers
of 2, as displayed here.
… Number System

• 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:

• Hexadecimal Number System:


• It 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.
• Hexadecimal number system is also a positional value system with where each digit has its value
expressed in powers of 16, as shown here:
Number System Relationship
Number system Conversion

• Decimal to Binary and Vice versa


• Decimal numbers can be converted to binary by repeated division of the number by 2 while
recording the remainder.
• E.g. 4310 = ?2

• The remainders are to be read from bottom to top to obtain the binary equivalent.

4310 = 1010112
Number system Conversion

• Decimal to Octal
• Decimal numbers can be converted to octal by repeated division of the number by 8 while
recording the remainder.
• E.g. 47310 = ?8

• The remainders are to be read from bottom to top to obtain the octal equivalent.

47310 = 7318
Number system Conversion

• Decimal to Hexadecimal
• Decimal numbers can be converted to hexadecimal by repeated division of the number by 16 while
recording the remainder.
• E.g. 47310 = ?8

• The remainders are to be read from bottom to top to obtain the hexadecimal equivalent.

42310 = 1A716
Number system Conversion

• Binary to Octal and Vice versa


• To convert a binary number to octal number, these steps are followed −
• Starting from the least significant bit, make groups of three bits.
• If there are one or two bits less in making the groups, 0s can be added after the most
significant bit
• Convert each group into its equivalent octal number
• E.g. 101100101012 = ?8

010 110 010 101

2 6 2 5

101100101012 = 26258
…cont’d

• Octal to Binary
• To convert an octal number to binary, each octal digit is converted to its 3-bit binary equivalent
according to this table.

• E.g. 26258 = ?2
2 6 2 5

010 110 010 101

26258=101100101012
Number system Conversion

• Binary to Hexadecimal and Vice versa


• To convert a binary number to octal number, these steps are followed −
• Starting from the least significant bit, make groups of 4 bits.
• If there are one or two bits less in making the groups, 0s can be added after the most
significant bit
• Convert each group into its equivalent octal number
• E.g. 111101101012 = ?16

0111 1011 0101

7 B 5

111101101012 = 7B516
…cont’d

• Hexadecimal to Binary
• To convert an hexadecimal number to binary, each hexadecimal digit is converted to its 4-bit binary
equivalent according to this table.

Binary 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111

Hex.Dec 1 2 3 4 5 6 7 8 9 A B C D E F

• E.g. 6A516 = ?2
6 A 5

0110 1010 0101

6A516=110101001012
Number system Conversion

• Octal to Hexadecimal and Vice versa


• Conversion from Octal to hexadecimal
• Convert the Octal to Decimal and then the Decimal to hexadecimal
• Convert the Octal to binary and then the binary to Hexadecimal
• Conversion from Hexadecimal to octal
• To convert from hexadecimal to Octal, first convert the hexadecimal to Decimal and then the
binary to Octal.
• To convert from hexadecimal to Octal, first convert the hexadecimal to Binary and then the
binary to Octal.
Number system Conversion

• Binary, octal and Hexadecimal to Decimal number


• To convert binary, octal and hexadecimal to decimal number, we just need to add the product of
each digit with its positional value.
XYZb = (X*b2 + Y*b1 + Z*b0)10
• E.g.
a. 1011012 = ?10

(1*25 + 0*24 + 1*23 + 1*22 + 0*21 + 1*20) = 32+8+4+1=4510


b. 528 = ?10

(5*81 + 2*80) = 40+2=4210

c. A1016 = ?10

(A*162 + 1*161 + 0*160) = 2560+16+0=257610


Summary of conversion from one base to another base
From base To base Method
2 10 Expand binary number in powers of 2
10 2 Factor the decimal number by 2
2 8 Group 3 binary digits together

8 2 Each Octal digit is converted to 3 binary digits


2 16 Group 4 binary digits together
16 2 Each hexadecimal digit is converted to 4 binary digits
8 10 Expand the number in powers of 8
10 8 Factor the decimal number by 8
16 10 Expand the number in powers of 16
10 16 Factor the decimal number by 16
8 16 Go from 8 …….2…….16
16 8 Go from 16 …….2…….8
Number system conversion with fractions
• Converting decimal numbers with fractions to Binary, Octal and Hexadecimal.
• First change the integer part to its equivalent other number system.
• Multiply the fractional part by base need to convert it and take out the integer value, and again multiply the fractional
part of the result by the base and take out the integer part, continue this until the product is 0.
• Finally, Collect the integer values from top to bottom & concatenate with the integer part.
• Example: Convert the Decimal 0.25 to its Equivalent Binary.
a. 0.25 * 2

0.25
*2 Exercise:
0 .50 1. Convert 12.2510 to Octal
*2 2. Convert 17.5 to Hexadecimal
1 .00
The Binary equivalent of .25(10) is .01(2)
Number system conversion with fractions
• Converting Binary, Octal and Hexadecimal numbers with fractions to Decimal.

• To convert binary, octal and hexadecimal with fractions to decimal number, we just need to add the
product of each digit with its positional value.
• XYZ.UVb = (X*b2 + Y*b1 + Z*b0 + U*b-1 + V*b-2)10
• Exercise:
a. 1001.012 = ?10

(1*23 + 0*22 + 0*21 + 1*20 + 0*2-1 + 1*2-2) = 8+0+0+1+0+0.25=9.2510

b. 56.328 = ?10
c. FF.A16 = ?10
Number system conversion with fractions

• Conversion from Binary with fraction to Octal/hexadecimal

• Group three/four digits together starting from the last digit of the integer part, and if there is less number of digits add some
zeros in the beginning.

• Group three/ four digits together starting from the first digit of the fractional part, and if there is less number of digits add some
zeros to the end.

• Covert each group of the integer and the fractional part to their equivalent Octal/hexadecimal and collect the results by adding
point (.) to separate the integer part from the fractional part.

• Ex1:- a. 1010.101012 = 001 010. 101 0102 = >> To Octal

1 2 .5 2 8

• = 1010. 1010 10002 = >> To hexadecimal

• A . A 8 16

Ex 2:- Covert 1010.01112 to octal


Ex3:- Covert 1110101.101112 to hexadecimal
Binary Arithmetic
• Binary arithmetic is essential part of all the digital computers and many other digital system.
• Binary Addition:
• It is a key for binary subtraction, multiplication, division. There are four rules of binary addition.

In fourth case, a binary addition is creating a


sum of (1 + 1 = 10) i.e. 0 is written in the given
column and a carry of 1 over to the next
column.

Example: 11010 + 1100 =>>


1 1 0 1 0
0 1 1 0 0

10 1 0 1 1 0
Binary Arithmetic
• Binary Subtraction:
• Subtraction and Borrow, these two words will be used very frequently for the binary subtraction. There are four rules of
binary subtraction.

With borrow


Binary Arithmetic
• Binary Multiplication:
• Binary multiplication is similar to decimal multiplication. It is simpler than decimal multiplication because only 0s and 1s are
involved. There are four rules of binary multiplication.

• Example – Multiplication:
Binary Arithmetic

• Binary Division:
• Binary division is similar to decimal division. It is called as the long division procedure.
Computer Coding Methods

• Computer codes are used for internal representation of data in computers

• As computers use binary numbers for internal data representation, computer codes use

binary coding schemes

• In binary coding, every symbol that appears in the data is represented by a group of bits

• The group of bits used to represent a symbol is called a byte.

• Commonly used computer codes are BCD, EBCDIC, and ASCII Codes
Computer Coding Methods

• BCD (6-bits)

• BCD stands for Binary Coded Decimal

• It is one of the early computer codes

• It uses 6 bits to represent a symbol

• It can represent 64 (26) different characters


Computer Coding Methods

• EBCDIC

• EBCDIC stands for Extended Binary Coded


Decimal Interchange Code
• It uses 8 bits to represent a symbol

• It can represent 256 (28) different characters


Computer Coding Methods

• ASCII

• ASCII stands for American Standard Code for Information


Interchange.
• ASCII is of two types – ASCII-7 and ASCII-8

• ASCII-7 uses 7 bits to represent a symbol and can


represent 128 (27) different characters
• ASCII-8 uses 8 bits to represent a symbol and can
represent 256 (28) different characters
• First 128 characters in ASCII-7 and ASCII-8 are same
Computer Coding Methods
Representation of negative numbers and Arithmetic

• There are different ways of representing negative numbers in a computer.


1. Sign Magnitude Representation
2. One’s Complement Representation
3. Two’s Complement Representation
1. Sign magnitude Representation
• In signed binary representation, the left-most bit is used to
indicate the sign of the number.
• In this method,
• 0 is used to denote a positive number and
• 1 is used to denote a negative number.
• magnitude part will be the same for the negative and
positive values • Example 1: Represent-12 using 5-bits sign magnitude
representation
• For example,
first we convert 12 to binary i.e. 1100
• 11111111 represents-127 while,
• 01111111 represents + 127
Now -12 = 11100

• for n-bit sign magnitude representation the range of values • Example 2: Represent –24 using 8-bits sign magnitude
that can be represented are representation
• – (2 n-1-1 ) to (2 n-1-1). 24 = 00011000
-24 = 10011000
One’s Complement

• In one’s complement representation, all positive integers are represented in their correct binary
format. However, for negative numbers, it can be obtained by complementing every bit in the original
representation.
• Each 0 is transformed into a 1 and each 1 into a 0. Each 0 is transformed into a 1 and each 1 into a 0.
• For example:
+3 = 0000 0011 • Example 1: Add -4 and +6 using 8-bits one’s complement

-3 = 1111 1100 - 4 is 11111011


+ 6 is 00000110
The sum is 00000001
(1) +
00000010
Two’s Complement

• A negative number represented in two’s complement is obtained by first computing the one’s
complement and then add one.
• Each 0 is transformed into a 1 and each 1 into a 0. Each 0 is transformed into a 1 and each 1 into a 0.
• For example:
+3 = 0000 0011 • Example 1: Add 4 and -3 using 8-bits Two’s complement
-3 = + 4 is 00000100
2’s comp= One’s comp +1 - 3 is 11111101

1111 1100+1 = 1111 1101 The sum is (1)00000001

00000001
End

You might also like