Presentation is loading. Please wait.

Presentation is loading. Please wait.

Memory Terminology & Data Representation CSCI 1060 Fall 2006.

Similar presentations


Presentation on theme: "Memory Terminology & Data Representation CSCI 1060 Fall 2006."— Presentation transcript:

1 Memory Terminology & Data Representation CSCI 1060 Fall 2006

2 CSCI 1060 — Fall 2006 — 2 Outline Memory Terminology Instruction/Data Representation –Decimal Base –Binary to Decimal –Decimal to Binary –Hexadecimal to Decimal –Decimal to Hexadecimal –Hexadecimal to Binary ASCII Codes

3 CSCI 1060 — Fall 2006 — 3 Outline Memory Terminology Instruction/Data Representation –Decimal Base –Binary to Decimal –Decimal to Binary –Hexadecimal to Decimal –Decimal to Hexadecimal –Hexadecimal to Binary ASCII Codes

4 CSCI 1060 — Fall 2006 — 4 Memory Terminology Memory is comprised of sequences of binary digits — bits Smallest measure of memory, two values, 0 or 1 (off or on) Four bits is a nibble Eight bits is a byte — can represent a single character ASCII code – American Standard Code for Information Interchange

5 CSCI 1060 — Fall 2006 — 5 Memory Terminology 1 kilobyte = 2 10 bytes, not 1,000 bytes 1 megabyte = 2 20 bytes (1,048,576 bytes) 1 gigabyte = 2 30 bytes 1 terabyte = 2 40 bytes 1 petabyte = 2 50 bytes … and so on, See Figure 2 B, KB, MB, GB represent bytes b, kb, mb, gb represent bits

6 CSCI 1060 — Fall 2006 — 6 Memory Terminology How many bytes are in 4 megabytes? 1 megabyte = 2 20 bytes = 1,048,576 bytes 4 megabytes = 4 * 2 20 bytes = 4,194,304 bytes How many bytes are in 2 gigabytes? 1 gigabyte = 2 30 bytes = 1,073,741,824 bytes 2 gigabytes = 2 * 2 30 bytes = 2,147,483,648 bytes

7 CSCI 1060 — Fall 2006 — 7 Memory Terminology How many bits are there in 32 kilobytes? 1 byte = 8 bits 32 kilobytes = 32 * 2 10 * 8 bits = 262,144 bits How many nibbles in 1 kilobyte? 1 nibble = 4 bits, 1 byte = 8 bits 1 kilobyte = 2 10 bytes * 8 bits / 4 bits = 2,048 nibbles

8 CSCI 1060 — Fall 2006 — 8 Outline Memory Terminology Instruction/Data Representation –Decimal Base –Binary to Decimal –Decimal to Binary –Hexadecimal to Decimal –Decimal to Hexadecimal –Hexadecimal to Binary ASCII Codes

9 CSCI 1060 — Fall 2006 — 9 Outline Memory Terminology Instruction/Data Representation –Decimal Base –Binary to Decimal –Decimal to Binary –Hexadecimal to Decimal –Decimal to Hexadecimal –Hexadecimal to Binary ASCII Codes

10 CSCI 1060 — Fall 2006 — 10 Instruction/Data Representation Decimal Base Decimal numbers are in base 10 Digits are 0-9 Increment the next space to the left when each slot is “full” Can expand a number like 536: –5*10 2 + 3*10 1 + 6*10 0 = 5*100 + 3*10 + 6*1 = 536 Other number systems work exactly the same way

11 CSCI 1060 — Fall 2006 — 11 Outline Memory Terminology Instruction/Data Representation –Decimal Base –Binary to Decimal –Decimal to Binary –Hexadecimal to Decimal –Decimal to Hexadecimal –Hexadecimal to Binary ASCII Codes

12 CSCI 1060 — Fall 2006 — 12 Instruction/Data Representation Binary to Decimal Binary numbers are in base 2 Digits are 0 or 1 Can expand a binary number like 1101 0111: –1*2 7 + 1*2 6 + 0*2 5 + 1*2 4 + 0*2 3 + 1*2 2 + 1*2 1 + 1*2 0 = –128 + 64 + 0 + 16 + 0 + 4 + 2 + 1 = 215 Often, people will separate binary numbers into nibbles for readability

13 CSCI 1060 — Fall 2006 — 13 Instruction/Data Representation Convert 0111 to decimal 0*2 3 + 1*2 2 + 1*2 1 + 1*2 0 = 4 + 2 + 1 = 7 Convert 1100 1100 to decimal 1*2 7 + 1*2 6 + 0*2 5 + 0*2 4 + 1*2 3 + 1*2 2 + 0*2 1 + 0*2 0 = 128 + 64 + 8 + 4 = 204 Convert 1010 0101 to decimal 1*2 7 + 0*2 6 + 1*2 5 + 0*2 4 + 0*2 3 + 1*2 2 + 0*2 1 + 1*2 0 = 128 + 32 + 4 + 1 = 165

14 CSCI 1060 — Fall 2006 — 14 Outline Memory Terminology Instruction/Data Representation –Decimal Base –Binary to Decimal –Decimal to Binary –Hexadecimal to Decimal –Decimal to Hexadecimal –Hexadecimal to Binary ASCII Codes

15 CSCI 1060 — Fall 2006 — 15 Instruction/Data Representation Decimal to Binary Find the powers of two that add up to the decimal number Two methods for accomplishing this: –Brute Force –Algorithmically Algorithmically will apply to any number system

16 CSCI 1060 — Fall 2006 — 16 Instruction/Data Representation Decimal to Binary – Brute Force Find powers of two up to some arbitrary number, use as a chart (See Figure 3) Identify the biggest power of two that will go into the number and then subtract it Repeat until you get a difference of 0 List all powers of two as placeholders and put 1s where any power of two was used

17 CSCI 1060 — Fall 2006 — 17 Instruction/Data Representation Decimal to Binary – Brute Force Convert 152 from decimal to binary 152 – 128 = 24 – 16 = 8 – 8 = 0 _ _ _ _ 1 0 0 1 1 0 0 0

18 CSCI 1060 — Fall 2006 — 18 Instruction/Data Representation Decimal to Binary – Brute Force Convert 201 from decimal to binary 201 – 128 = 73 – 64 = 9 – 8 = 1 – 1 = 0 _ _ _ _ 1 1 0 0 1 0 0 1

19 CSCI 1060 — Fall 2006 — 19 Instruction/Data Representation Decimal to Binary – Algorithmically Continually divide the number by two When you reach 1, divide one more time Take the remainder (guaranteed to be either 1 or 0) and form a string of 1s and 0s Reverse the string to get the binary representation

20 CSCI 1060 — Fall 2006 — 20 Instruction/Data Representation Decimal to Binary – Algorithmically Convert 152 from decimal to binary –152 / 2= 76 r 0 –76/ 2 = 38 r 0 –38 / 2 = 19 r 0 –19 / 2 = 9 r 1 –9 / 2 = 4 r 1 –4 / 2 = 2 r 0 –2 / 2 = 1 r 0 –1 / 2 = 0 r 1 Read remainders from bottom to top (152) 10 = (1001 1000) 2

21 CSCI 1060 — Fall 2006 — 21 Instruction/Data Representation Decimal to Binary – Algorithmically Convert 201 from decimal to binary –201 / 2 = 100 r 1 –100/ 2 = 50 r 0 –50 / 2 = 25 r 0 –25 / 2 = 12 r 1 –12 / 2 = 6 r 0 –6 / 2 = 3 r 0 –3 / 2 = 1 r 1 –1 / 2 = 0 r 1 Read remainders from bottom to top (201) 10 = (1100 1001) 2

22 CSCI 1060 — Fall 2006 — 22 Outline Memory Terminology Instruction/Data Representation –Decimal Base –Binary to Decimal –Decimal to Binary –Hexadecimal to Decimal –Decimal to Hexadecimal –Hexadecimal to Binary ASCII Codes

23 CSCI 1060 — Fall 2006 — 23 Instruction/Data Representation Hexadecimal to Decimal Hexadecimal numbers are in base 16 Digits are 0-F (10 = A, 11 = B, etc.) Can expand a hexadecimal number like 1128: –1*16 3 + 1*16 2 + 2*16 1 + 8*16 0 = –4096 + 256 + 32 + 8 = 4392 Can expand a hexadecimal number like AF: –A*16 1 + F*16 0 = –160 + 15 = 175

24 CSCI 1060 — Fall 2006 — 24 Instruction/Data Representation Convert 589 to decimal –5*16 2 + 8*16 1 + 9*16 0 = 1280 + 128 + 8 = 1417 Convert FA8 to decimal –F*16 2 + A*16 1 + 8*16 0 = 3840 + 160 + 8 = 4008 Convert 1531 to decimal –1*16 3 + 5*16 2 + 2*16 1 + 1*16 0 = 4096 + 1280 + 48 + 1 = 5425

25 CSCI 1060 — Fall 2006 — 25 Outline Memory Terminology Instruction/Data Representation –Decimal Base –Binary to Decimal –Decimal to Binary –Hexadecimal to Decimal –Decimal to Hexadecimal –Hexadecimal to Binary ASCII Codes

26 CSCI 1060 — Fall 2006 — 26 Instruction/Data Representation Decimal to Hexadecimal Continually divide the number by sixteen When you reach a number fifteen or below, stop, that is your last digit (convert if necessary) Reverse the string of remainders to get the hexadecimal representation

27 CSCI 1060 — Fall 2006 — 27 Instruction/Data Representation Decimal to Hexadecimal Convert 152 from decimal to hexadecimal –152 / 16= 9 r 8 –9 / 16 = 0 r 9 Read remainders from bottom to top (152) 10 = (98) 16

28 CSCI 1060 — Fall 2006 — 28 Instruction/Data Representation Decimal to Hexadecimal Convert 201 from decimal to hexadecimal –201 / 16 = 12 r 9 –12 / 16 = 0 r 12 Read remainders from bottom to top (201) 10 = (C9) 16

29 CSCI 1060 — Fall 2006 — 29 Instruction/Data Representation Decimal to Hexadecimal Convert 5645 from decimal to hexadecimal –5645 / 16 = 352 r 13 –352 / 16 = 22 r 0 –22 / 16 = 1 r 6 –1 / 16 = 0 r 1 Read remainders from bottom to top (5645) 10 = (160D) 16

30 CSCI 1060 — Fall 2006 — 30 Outline Memory Terminology Instruction/Data Representation –Decimal Base –Binary to Decimal –Decimal to Binary –Hexadecimal to Decimal –Decimal to Hexadecimal –Hexadecimal to Binary ASCII Codes

31 CSCI 1060 — Fall 2006 — 31 Instruction/Data Representation Hexadecimal to Binary Substitute the binary value of each digit Can use intermediate step of converting each “slot” to decimal first (Do NOT calculate overall value) A8 = 10 8 = 1010 1000 98 = 9 8 = 1001 1000 C9 = 12 9 = 1100 1001

32 CSCI 1060 — Fall 2006 — 32 Outline Memory Terminology Instruction/Data Representation –Decimal Base –Binary to Decimal –Decimal to Binary –Hexadecimal to Decimal –Decimal to Hexadecimal –Hexadecimal to Binary ASCII Codes

33 CSCI 1060 — Fall 2006 — 33 ASCII Codes American Standard Code for Information Interchange Used to represent data For instance, the letter ‘A’ is a decimal 65, binary value of 0100 0001


Download ppt "Memory Terminology & Data Representation CSCI 1060 Fall 2006."

Similar presentations


Ads by Google