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

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

DATA (in binary Digits)

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


งานนำเสนอเรื่อง: "DATA (in binary Digits)"— ใบสำเนางานนำเสนอ:

1 DATA (in binary Digits)
Binary Concepts 1 -- OFF -- ON DATA (in binary Digits)

2 Data Representation Main() { printf(“ Hello”);
printf(“We are enjoying a world of alphapbetical coding”); }

3 Decimal Number System (6*10)
In the decimal number system the successive position to the left of the decimal point represent units, tens, hundreds, thousands etc. (3 * 100) + (6*10) + (5*1) = 365 The position of the number affects its value. These kind of number systems therefore are called positional number system. The value of each digit in the number system is determined by: The digit itself The position of the digit in the number itself The base/radix of the system. Base Position number (6*10)

4 Binary Number System The binary number system has a base of two and symbols used are 0 and 1. In this number system, as we move to the left, the value of the digit will be two times greater than its predecessor because the base is two. Thus the value of the places are :   64  32  16  8  4  2  1 Binary Number Least Significant bit Most Significant bit

5 Converting Decimal to Binary
Remainder Divide the decimal number by the base of the required number system. Note the remainder in one column and divide the quotient again with the base. Keep repeating this process until there are no numbers left to be divided. Reading of the remainder in the reverse order of them being written down will give us the required number. Now let us convert the decimal number 52 to its binary equivalent.

6 Octal Number System The octal system has the base of 8. The value increase from right to left as 1, 8, 64, 512, 4096. The decimal value of an octal number 1204 can be computed as : 1204 = (1 * 512) + (2 * 64) + (0 * 8) + (4 * 1)  =   = 644

7 Octal Number System To convert a number from binary to octal and vice versa, the following table must be kept in mind:  Binary Octal   000 0 001 1 010 2 011 3 100             4 101 5 110             6 111             7

8 Converting from Binary to Octal
The binary number must be divided into groups of three from the octal point- to the right in case of the fractional portion and to the left in case of the integer portion. Each group can then be replaced with their octal equivalent. We may add zero to the left of the number if required. For example : Binary   52524 is the octal equivalent of the given binary number.

9 Converting from Octal to Binary
Each octal digit is replaced with the appropriate ‘triple’ of binary digits. For example :  6         5 Similarly the binary equivalent of the octal number 65 is

10 Hexadecimal Number System
Hexadecimal Decimal 0 0 1 1 2 2 3 3 4 4 5 5 6 6 9 9 A 10 B 11 C 12 D 13 E 14 F 15 The hexadecimal number system has a base of 16, so the value increases from right to left as 1, 16, 256, 4096, 65536… We need to keep a simple table in mind before we attempt any conversion from hexadecimal or vice-versa. Thus the decimal equivalent of a hexadecimal number A0119 can be computed as:  = (10 * 65,536) + (0 * 4,096) + (1 * 256) + (1 * 16) + (9 * 1) = 6,55, =6,55,641

11 Converting Binary to Hexadecimal
To convert a binary number to its hexadecimal equivalent we split the numbers into groups of four outwards, as before. Each of these groups of four are directly converted into their hexadecimal equivalent. e.g. Binary Binary Hexadecimal A C (From the table)

12 Converting Hexadecimal to Binary
The conversion from hexadecimal to binary consists of writing off the binary equivalent of each hexadecimal digit in groups of four. For Example: hexadecimal 1901A0412C A C Thus the required binary number can be written as: The leading zeros have been omitted. This is because it has no particular significance. It is an interesting fact that computer primary storage addressing is usually expressed in hexadecimal notation.

13

14 คาแรกเตอร์ (ASCII)

15

16

17 คาแรกเตอร์ (EBCDIC)

18

19 คาแรกเตอร์ (Unicode)

20 การรับค่าตัวอักษรทาง Keyboard

21 การรับค่าตัวอักษรทางอื่น ๆ
Optical Character Recognition Barcode Reader Magnetic Stripe Reader Voice Input

22 เลขจำนวนเต็ม (Integer)
เลขจำนวนเต็มแบบที่ไม่มีเครื่องหมาย (Unsigned Integer) กรณีไม่มีเครื่องหมาย ถ้าใช้จำนวนบิต n บิต จะแทนเลขจำนวนเต็มไม่มีเครื่องหมายได้ ตั้งแต่ 0 ถึง 2n-1 เช่น n = 16 จะแทนเลขจำนวนเต็มได้ตั้งแต่ 0 ถึง เป็นต้น

23

24 เลขจำนวนเต็มแบบที่มีเครื่องหมาย (Signed Integer)
1. sign magnitude ใช้บิตซ้ายสุด (most significant bit) แทนเครื่องหมาย โดยที่ 0 แทนเครื่องหมายบวก และ 1 แทนเครื่องหมายลบ บิตที่เหลือใช้แทนขนาดของตัวเลข most significant bit least significant bit n n … sign magnitude

25 เลขจำนวนเต็มแบบที่มีเครื่องหมาย (Signed Integer)
เช่น สมมุติว่าใช้ จำนวนบิต 8 บิต แทนเลขจำนวน +5 และ –5 ได้เป็น และ เป็นต้น ถ้าใช้จำนวน n บิต จะแทนเลขจำนวนเต็มแบบมีเครื่องหมาย ได้ตั้งแต่ – (2n-1 – 1) ถึง +(2n-1- 1) เช่น n = 16 จะแทนเลขจำนวนเต็มมีเครื่องหมายได้ตั้งแต่ –32767 ถึง เป็นต้น โดยที่ 0 แทนได้ทั้ง +0 และ –0

26 เลขจำนวนเต็มแบบที่มีเครื่องหมาย (Signed Integer)
2. one complement ใช้บิตซ้ายสุด (most significant bit) แทนเครื่องหมาย โดยที่ 0 แทนเครื่องหมายบวก และ 1 แทนเครื่องหมายลบ เช่นกัน การแทนเลขบวก จะเหมือนกับแบบ sign magnitude แต่การแทนตัวเลขลบ จะต่างกัน แบบ one complement จะแทนตัวเลขลบโดยการ ทำ complement (เปลี่ยนจากเลข 0 เป็น 1 และ เปลี่ยนจากเลข 1 เป็น 0) กับ magnitude เช่น สมมุติว่าใช้ จำนวนบิต 8 บิต แทนเลขจำนวน +5 และ –5 ได้เป็น และ เป็นต้น

27 เลขจำนวนเต็มแบบที่มีเครื่องหมาย (Signed Integer)
ถ้าใช้จำนวน n บิต จะแทนเลขจำนวนเต็มแบบมีเครื่องหมาย ได้ตั้งแต่ – (2n-1 – 1) ถึง +(2n-1- 1) เช่น n = 16 จะแทนเลขจำนวนเต็มมีเครื่องหมายได้ตั้งแต่ –32767 ถึง เป็นต้น โดยที่ 0 แทนได้ทั้ง +0 และ –0

28 เลขจำนวนเต็มแบบที่มีเครื่องหมาย (Signed Integer)
2. two complement ใช้บิตซ้ายสุด (most significant bit) แทนเครื่องหมาย โดยที่ 0 แทนเครื่องหมายบวก และ 1 แทนเครื่องหมายลบ เช่นกัน การแทนเลขบวก จะเหมือนกับแบบ sign magnitude แต่การแทนตัวเลขลบ จะต่างกัน แบบ two complement จะแทนตัวเลขลบโดยการ ทำ complement (เปลี่ยนจากเลข 0 เป็น 1 และ เปลี่ยนจากเลข 1 เป็น 0) กับ magnitude แล้วบวกด้วยหนึ่ง เช่น สมมุติว่าใช้ จำนวนบิต 8 บิต แทนเลขจำนวน +5 และ –5 ได้เป็น และ เป็นต้น

29 เลขจำนวนเต็มแบบที่มีเครื่องหมาย (Signed Integer)
– (2n-1) ถึง +(2n-1- 1) เช่น n = 16 จะแทนเลขจำนวนเต็มมีเครื่องหมายได้ตั้งแต่ –32768 ถึง เป็นต้น โดยที่ 0 แทนด้วย +0 เท่านั้น

30 Overflow

31

32

33


ดาวน์โหลด ppt DATA (in binary Digits)

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


Ads by Google