งานนำเสนอกำลังจะดาวน์โหลด โปรดรอ

งานนำเสนอกำลังจะดาวน์โหลด โปรดรอ

Data representation (การแทนข้อมูล)

งานนำเสนอที่คล้ายกัน


งานนำเสนอเรื่อง: "Data representation (การแทนข้อมูล)"— ใบสำเนางานนำเสนอ:

1 Data representation (การแทนข้อมูล)
ระบบตัวเลขและการแปลงเลขฐาน (Number System and Conversion) ระบบตัวเลข (Number System) ฐาน (Base or radix) - ค่าที่จะบอกให้ทราบว่าเลข ในระบบนั้นๆ จะมีสัญลักษณ์ใช้ทั้งหมดกี่ตัว หรือ มีค่าตัวเลข โดดๆ (absolute value) กี่ตัว ระบบจำนวนที่ใช้ในทางคอมพิวเตอร์ ประกอบด้วย ระบบเลขฐานสอง (Binary Number System) ประกอบด้วยเลข 0,1 ระบบเลขฐานแปด (Octal Number System) ประกอบด้วยเลข 0 - 7 ระบบเลขฐานสิบ (Decimal Number System) ประกอบด้วยเลข 0 - 9 ระบบเลขฐานสิบหก (Hexadecimal Number System) ประกอบด้วย ตัว เลข และ A - F

2 decimal - The decimal number system uses the
radix 10. The 10 symbols are 0,1,2,3,4,5,6,7,8,9. x x x x 10-1 binary - The binary system uses the radix 2. The two digits symbols used are 0 and 1. 1.) 1x25 + 0x24 + 1x23 + 1x22 + 0x21 + 1x20 = 45

3 2.) การแปลง (101101)2 เป็นเลขฐานสิบ
บิทซ้ายสุด คูณด้วย 2 และบวกบิทถัดไป(2 x 1) + 0 = 2 คูณด้วย 2 และบวกบิทถัดไป(2 x 2) + 1 = 5 คูณด้วย 2 และบวกบิทถัดไป(2 x 5) + 1 = 11 คูณด้วย 2 และบวกบิทถัดไป(2 x 11) + 0 = 22 คูณด้วย 2 และบวกบิทถัดไป(2 x 22) + 1 = 45 ดังนั้น (101101)2 = (45)10

4 Binary Data Representation

5 octal - The octal system uses the radix 8. The
eight symbols used are 0,1,2,3,4,5,6,7 736.4 = 7 x x x x 8-1 = 7 x x x 1 + 4/8 = 478.5

6 hexadecimal - The hexadecimal system uses the radix 16
The 16 symbols used are 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F F3 = F x x 160 = 15 x x 1 = 243 เขียนเป็นสูตรได้ดังนี้

7 Conversion - Conversion from decimal to binary, octal, and hexadecimal
Example Conversion of decimal into binary Integer = 41 Fraction = x 2 = x 2 = x 2 = x 2 = 2 1 1 0 0 1

8 = 1 x x x 23 + 0 x x x 20 = = 41

9

10 Binary, octal, and hexadecimal conversion
1 2 7 5 4 3 A F 6 3 Binary, octal, and hexadecimal conversion

11 การคำนวณในระบบเลขฐานต่างๆ
การบวกเลขฐาน เลขฐานสอง เลขฐานสิบ เลขฐานแปด เลขฐานสิบหก B = ?

12 การคำนวณในระบบเลขฐานต่างๆ
การลบเลขฐาน เลขฐานสอง เลขฐานแปด เลขฐานสิบหก F C A 4 B 8 = ?

13 การลบโดยใช้ Complements
- r’s complement - (r - 1)’s complement การคำนวณหาค่า complements ของตัวเลขฐาน r ใดๆ สามารถหาจากสูตรดังนี้คือ

14 ตัวอย่าง การหา 2’s complement ของเลขฐานสอง 100110
r’s complement = rn – N 2’s complement = 26 – 38 = 64 – 38 = 26 2’s complement = (011010)2 1’s complement = rn – N – 1 = 64 – 38 – 1 = 25 1’s complement = (011001)2 ข้อสังเกตในการหา complement ของเลขฐานสองอย่างง่าย คือ เลชฐานสอง ( )2 1’s complement ( )2 2’s complement ( )2

15 ตัวอย่าง การหา complement ของเลขฐานอื่นๆ
เลขฐานสิบ = 34974 9’s complement = 10’s complement = เลขฐานแปด = 115 7’s complement = 662 8’s complement = 663 เลขฐานสิบหก = A719C 15’s complement = 58E63 16’s complement = 58E64

16 The subtraction of two n-digit unsigned numbers M - N
by using r’s complement M >= N (M = 72532, N = 13250) radix 10 M = 72532 10’s complement of N = Sum = Discard end carry = Answer = 59282

17 M < N (M = 13250, N = 72532) M = 13250 10’s complement of N = Sum = There is no end carry Answer is negative (10’s complement of 40718) Example = ? = ?

18 Subtraction with binary number. Using X = 1010100
and Y = X - Y X = 2’s complement of Y = Sum = Discard end carry 2^7 = Answer X - Y =

19 Y - X Y = 2’s complement of X = Sum = There is no end carry Answer is negative (2’s complement of )

20 การคูณ เลขฐานแปด การหาร เลขฐานแปด
74 x

21 Multiplication Algorithm
Multiplicand x Multiplier 10111 00000 Product

22 Numerical Example for Binary Multiplier
Multiplicand B = E A Q SC Multiplier in Q Qn = 1 ; add B First partial product Shift right EAQ Qn = 1 ; add B Second partial product Shift right EAQ Qn = 0 ; shift right EAQ Qn = 0 ; shift right EAQ Fifth partial product Shift right EAQ Final product in AQ =

23 Integer signed numbers representation
When an integer binary number is positive, the sign is represented by 0 and the magnitude by positive binary number. When the number is negative, the sign is represented by 1 and the rest of number may be represented in one of three possible ways: 1. Signed - magnitude representation 2. Signed - 1’s complement representation 3. Signed - 2’s complement representation

24 Example number 14 -14 In signed - magnitude representation -14 In signed - 1’s complement -14 In signed - 2’s complement sign bit

25 CPU Data Types

26 รหัสข้อมูล (Data Representation) หมายถึง รหัสที่ใช้แทน
ตัวเลข ตัวอักษร สัญลักษณ์ต่างๆ ที่ประกอบอยู่ในคำสั่งและ ข้อมูล เพื่อใช้ในการประมวลผล สามารถแบ่งได้ 2 ประเภทคือ - รหัสภายในระบบคอมพิวเตอร์ (Internal Code) เป็นรหัสที่ใช้แทนข้อมูลในหน่วยความจำของคอมพิวเตอร์ เช่น -รหัส BCD - Binary Code Decimal -รหัส EBCDIC - Extended Binary Coded Decimal Interchange Code - รหัส ASCII - American Standard Code for Information Interchange

27 - รหัส สมอ. - รหัส Unicode - รหัสภายนอกระบบคอมพิวเตอร์ (External Code) เป็นรหัสที่พัฒนาสำหรับบันทึกข้อมูลนอกเครื่องคอมพิวเตอร์ เช่นรหัสที่ใช้กับบัตรเจาะรู รหัสภายในคอมพิวเตอร์ แทนได้กับสภาวะของกระแสไฟฟ้า ตามจำนวนสายสัญญาณ เช่น ถ้ามีสายสัญญาณ 2 เส้น ก็สามารถสร้างรหัสแทนข้อมูลได้ 4 ค่า (คิดจาก 22 ) คือ

28 รหัสแทนข้อมูลอื่น ๆ BCD (Binary-Coded Decimal) ASCII (American Standard Code for Information Interchange) Binary Gray Code Excess-3 Excess-3 Gray EBCDIC (Extended BCD Interchange Code)

29 CPU Data Types

30 The message “Hello.” in ASCII

31 Error Detection Codes (รหัสตรวจสอบความผิดพลาด)
การส่งผ่านข้อมูลระหว่างสื่อบันทึกข้อมูลต่างๆ อาจมีข้อมูลบางส่วนผิดพลาดไป เช่น เปลี่ยนค่าจาก 1 เป็น 0 หรือ 0 เป็น 1 ซึ่งเป็นผลกระทบจากสภาพ แวดล้อมภายนอก เช่น มีสัญญาณรบกวนซึ่งสามารถ ตรวจสอบความผิดพลาดได้ โดยกำหนด bit พิเศษ ขึ้นมา 1 bit เรียกว่า parity bit bit ตรวจสอบนี้เป็น เลขฐานสอง 1 ตัว ที่ใช้ในการรวมเข้ากับกลุ่มของ เลขฐานสองที่เป็นข้อมูล เพื่อทำให้ผลรวมของตัวเลข ทั้งหมด (1 หรือ 0) เป็นจำนวนเลขคี่ (odd parity) หรือเป็นจำนวนเลขคู่ (even parity)

32 ตัวอย่าง Parity bit generation Message P(odd) P(even)

33 The ASCII codes for the letters A and F adjusted for odd parity

34 Data Types The data types may be classified as being one of the following categories: 1. numbers used in arithmetic computations 2. letters of alphabet used in data processing 3. other discrete symbols used for specific purposes All types of data, except binary numbers, are represented in computer registers in binary-coded form.

35 Summary Numeric data is stored using integer, real number, and floating point formats. Characters are converted to numbers by means of a coding table. Boolean vales can have only two values, true and false. Programs often need to define and manipulate data in larger and more complex units than primitive CPU data types.


ดาวน์โหลด ppt Data representation (การแทนข้อมูล)

งานนำเสนอที่คล้ายกัน


Ads by Google