Chapter 3 part i data representation

21
Data Representation Chapter 3 Part I

Transcript of Chapter 3 part i data representation

Page 1: Chapter 3 part i data representation

Data Representation

Chapter 3 Part I

Page 2: Chapter 3 part i data representation

Contents

Introduction to number system Different bases numbers Converting different bases numbers

into decimal Converting decimal numbers into

different bases Converting floating points

Page 3: Chapter 3 part i data representation

Objectives

At the end of this chapter, students should be able to: Explain the different bases number

system Convert numbers into different bases Convert floating numbers into different

bases

Page 4: Chapter 3 part i data representation

Introduction

Human use decimal (base 10) number system to

count and perform arithmetic. Computer

uses binary (base 2) number system. each digit is known as a bit (0 and 1).

Page 5: Chapter 3 part i data representation

Introduction

Computer stores and manipulates the bits in group of 8(byte), 16 (halfword), 32 (word) and 64 (double word).

Number of bits used in calculations affects the accuracy and size limitations of numbers manipulated by the computer.

Page 6: Chapter 3 part i data representation

Introduction

Counting in base 10 E.g.: 0, 1, 2, 3, …, 10, …, 100,…

10 (1 x 101 + 0 = 10 + 0)63 (6 x 101 + 3 x 100 = 60 + 3)747 (7 x 102 + 4 x 101 + 7 x 100 = 700 + 40 + 7)

Page 7: Chapter 3 part i data representation

Different bases numbers

Page 8: Chapter 3 part i data representation

Different bases numbers Number can be represented in different bases. Different name of bases:

Base 2 binary Base 3 ternary Base 4 quaternary Base 5 quinary Base 6 senary Base 7 septenary Base 8 octal Base 9 nonary Base 10 decimal Base 11 undenary Base 12 duodecimal Base 16 hexadecimal Base 20 vigesimal Base 60 sexagesimal

Page 9: Chapter 3 part i data representation

Different bases numbers

Base 2 includes (0, 1) Base 3 includes (0,1,2) Base 4 includes (0,1,2,3) Base 9 includes ? Base 12 includes ? Base 16 includes?

Page 10: Chapter 3 part i data representation

Different bases numbers

Base 2 0,1, 10, 11,100, 101, … Base 3 0,1,2, 10, 11, 12, 20, 21, … Base 4 0,1,2,3,10,11,12, 13, 20, … Base 9 ? Base 12 ? Base 16 ?

Page 11: Chapter 3 part i data representation

Converting different bases numbers into decimal

Page 12: Chapter 3 part i data representation

Converting different bases number into decimal

Counting in base 8 Example: 1278

(1 x 82) + (2 x 81) + (7 x 80) = 64 + 16 + 7 = 8710

Page 13: Chapter 3 part i data representation

Converting different bases numbers into decimal

Counting in base 2: E.g.:10112

(1 x 23) + 0 + (1 x 21) + (1 x 20) = 8+0+2+1 = 1110

Page 14: Chapter 3 part i data representation

Converting decimal numbers into different bases

Page 15: Chapter 3 part i data representation

Converting decimal numbers into different bases

Converting to base 8 E.g.: 30

30 / 8 = 3 Balance 63 / 8 = 0 Balance 33010 = 368

Page 16: Chapter 3 part i data representation

Converting decimal numbers into different bases

Converting to base 4 E.g.: 30

30 / 4 = 7 Balance 27 / 4 = 1 Balance 31 / 4 = 0 Balance 13010 = 1324

Page 17: Chapter 3 part i data representation

Converting decimal numbers into different bases

Converting to base 2 E.g.: 30

30 / 2 = 15 Balance 015 / 2 = 7 Balance 17 / 2 = 3 Balance 13 / 2 = 1 Balance 11 / 2 = 0 Balance 13010 = 111102

Page 18: Chapter 3 part i data representation

Converting floating points

Page 19: Chapter 3 part i data representation

Converting floating points

1010/2 = 5 Balance 0 5/2 = 2 Balance 12/2 =1 Balance 01/2 =0 Balance 11010

.250.25 X 2 = 0.5 00.5 X 2 = 1 1

01

•Convert decimal to base 2 floating number•E.g.: 10.25

1010.01

Page 20: Chapter 3 part i data representation

Converting floating points

101(1x22) + 0 + (1x20) 4 + 15

1101(1 x ½)+(1x ¼)+(1x 1/16)0.5 + 0.25 + 0.06250.8125

Converting floating points E.g.: 101.1101 Convert base 2 floating number to decimal

5.8125

Page 21: Chapter 3 part i data representation

End of Chapter 3 Part I