Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Foundations of Computer Science Chapter 2 Data Representation.

Similar presentations


Presentation on theme: "1 Foundations of Computer Science Chapter 2 Data Representation."— Presentation transcript:

1 1 Foundations of Computer Science Chapter 2 Data Representation

2 2 Outline 2.1 Data type 2.2 Data inside the computer 2.3 Representing data 2.4 Hexadecimal Notation 2.5 Octal Notation

3 3 2.1 Data Types 2.1 Data Types

4 4 Different Types of Data Data TextNumberImageAudioVideo Numbers, text, images, audio, and video are all forms of data. Computers need to process all types of data.

5 5 Multimedia The computer industry uses the term “multimedia” ( 多媒體 ) to define Information that contains numbers, text, images, audio, and video.

6 6 2.2 Data Inside The Computer 2.2 Data Inside The Computer

7 7 Bit Pattern All data types from outside a computer are transformed into a uniform representation called a bit pattern for processing by computers. A bit is the smallest unit of data that can be stored in a computer

8 8 Bit Pattern A bit pattern of length 8 is called a byte Byte also been used to measure the size of memory or other storage devices 1 byte = 8 bits 1 KB = 1024 bytes 1 MB = 1024 KB 2 bytes = 16 bits 1 GB = 1024 MB K : kilo ( 千 ) M: mega ( 百萬 ) G: giga ( 十億 ) 2 10 = 1024

9 9 Bit Pattern A switch, with its two states of on and off, can represent a bit(0 or 1) A bit pattern is a sequence of bits that can represent a symbol 1000101010111111

10 10 Examples of Bit Patterns Data are coded ( 邊碼 ) when they enter a computer and decoded ( 解碼 ) when they are presented to the user

11 11 2.3 Representing Data 2.3 Representing Data

12 12 Representing Symbols Using Bit Patterns How many bits are needed in a bit pattern to represent a symbol in a language?  Depend on how many symbols are in the set

13 13 Number of Symbols and Bit Pattern Length Number of Symbols Number of Symbols --------------------- 2 4 8 16 … 128 256 … 65,536 Bit Pattern Length Bit Pattern Length --------------------- 1 2 3 4 … 7 8 … 16

14 14 Codes Code: different sets of bit patterns have been designed to represent text symbols – ASCII: popular code for symbols – EBCDIC: used in IBM mainframes – Unicode ( 萬國碼 ): 16-bit code, allow a greater number of symbols – ISO: 32-bit code, allow a greater number of symbols

15 15 Coding Coding is the process of transforming data into a bit pattern

16 16 ASCII American Standard Code for Information Interchange ( 美國資訊交換標準碼 ) The code be developed from the American National Standards Institute (ANSI, 美國國 家標準局 ) ASCII uses 7 bits for each symbol 2 7 = 128

17 17 Some Features of ASCII ASCII uses a 7-bit pattern: 0000000 ~ 1111111 0000000  null character; 1111111  delete character There are 31 control (nonprintable) characters The numeric characters (0~9) are coded before letters

18 18 Some Features of ASCII There are several special printable characters The uppercase letters (A~Z) come before the lowercase letters (a~z) The upper and lowercase characters are distinguished by only 1 bit. (A  1000001; a  1100001) There are six special characters between the upper and lowercase letters

19 19 Extended ASCII To make the size of each pattern 1 byte (8 bits), the ASCII bit patterns are augmented with an extra 0 at the left. Extended ASCII uses a 8-bit pattern: 00000000 ~ 01111111

20 20 EBCDIC Extended Binary Coded Decimal Interchange Code ( 延伸的二進位十進制交 換碼 ) EBCDIC uses 8 bits for each symbols Only uses in IBM mainframes 2 8 = 256

21 21 Unicode Unicode ( 萬國碼 ) be designed from a coalition of hardware and software manufacturers Unicode uses 16 bits and can represent up to 65,536 (2 16 ) symbols

22 22 ISO International Organization for Standardization ( 國際標準化組織 ) ISO uses 32 bits and can represent up to 4,294,967,296 (2 32 ) symbols

23 23 Number Numbers are represented using the binary system Chapter 3

24 24 Images Images today are represented in a computer by one of two methods – Bitmap graphic ( 位元圖、點陣圖 ) – Vector graphic ( 向量圖 ) Image BitmapVector

25 25 Bitmap Graphic Image is divided into a matrix of pixels ( 像 數:圖畫元素 ), each pixel is assigned a bit pattern The size of the pixel depends on what is called the resolution ( 解析度 )

26 26 Representation of Color Pixels

27 27 Color and Gray-layer Images Color image RGB : 3 bytes Resolution: 512 * 512 = 26,624 pixels Image size: 512 * 512 * 3 = 79,872 bytes Gray-layer Image Gray-layer : 1 byte Resolution : 512 * 512 = 26,624 pixels Image size: 512 * 512 * 1 = 26,624 bytes

28 28 Vector Graphic If you want to rescale the bitmap graphic image, which creates a ragged or grainy look An image is decomposed into a combination of curves ( 曲線 ) and lines ( 直 線 ) Each curve or line is represented by a mathematical formula ( 數學方程式 ) Each time an image is drawn, the formula is reevaluated

29 29 Audio Audio data are transformed to bit patterns through sampling ( 取樣 ), quantization ( 量化 ), and coding ( 編碼 )

30 30 Video Video is a representation of images (called frames) in time, the combination of the images represents the video A movie is a series of frames shown one after another to create the illusion of motion Today video is normally compressed: MPEG

31 31 2.4 Hexadecimal Notation 2.4 Hexadecimal Notation

32 32 Hexadecimal Notation People find it difficult to manipulate bit patterns. Writing a long stream of 0s and 1s is tedious and prone to error A 4-bit pattern can be represented by a hexadecimal ( 十六進位 ) digit

33 33 Hexadecimal Digit Bit Pattern Bit Pattern ------------ 0000 0001 0010 0011 0100 0101 0110 0111 Hex Digit Hex Digit ------------ 0 1 2 3 4 5 6 7 Bit Pattern Bit Pattern ------------ 1000 1001 1010 1011 1100 1101 1110 1111 Hex Digit Hex Digit ------------ 8 9 A B C D E F

34 34 Binary to Hexadecimal and Hexadecimal to Binary Transformation 1111110011100100 F C E 4 0000 0001 0010 0011 0100 0101 0110 0111 0123456701234567 1000 1001 1010 1011 1100 1101 1110 1111 89ABCDEF89ABCDEF 1111110011100100 → xFCE4 → XFCE4 → FCE4 16

35 35 Example BinaryHexadecimal 1100 1110 0010? 000011100010? ?x24C 0000 0001 0010 0011 0100 0101 0110 0111 0123456701234567 1000 1001 1010 1011 1100 1101 1110 1111 89ABCDEF89ABCDEF

36 36 Example BinaryHexadecimal 1100 1110 0010xCE2 000011100010x0E2 001001001100x24C 0000 0001 0010 0011 0100 0101 0110 0111 0123456701234567 1000 1001 1010 1011 1100 1101 1110 1111 89ABCDEF89ABCDEF

37 37 Octal Notation A 3-bit pattern can be represented by a octal ( 八進位 ) digit

38 38 Octal Digit Bit Pattern Bit Pattern ------------ 000 001 010 011 Octal Digit Octal Digit ------------ 0 1 2 3 Bit Pattern Bit Pattern ------------ 100 101 110 111 Octal Digit Octal Digit ------------ 4 5 6 7

39 39 Binary to Octal and Octal to Binary Transformation 1 1 7 6 3 4 4 000 001 010 011 01230123 100 101 110 111 45674567 111110011100100 → 0176344 → o176344 → 176344 8 111110011100

40 40 Example BinaryOctal 101110010? 1100010? ?o24 000 001 010 011 01230123 100 101 110 111 45674567

41 41 Example BinaryOctal 101110010o562 1100010o142 010110o24 0000 0001 0010 0011 01230123 0100 0101 0110 0111 45674567

42 42 The End


Download ppt "1 Foundations of Computer Science Chapter 2 Data Representation."

Similar presentations


Ads by Google