Download presentation

Presentation is loading. Please wait.

Published byAli Stukes Modified over 2 years ago

1
CMSC 150 DATA REPRESENTATION CS 150: Mon 30 Jan 2012

2
What Happens When… 2

3
Steps Of An Executing Program 3 Initially, the program resides as a (binary) file on the disk

4
4 Steps Of An Executing Program When you click an icon to start a program…

5
5 Steps Of An Executing Program the program is copied from disk into memory (RAM)… the program is copied from disk into memory (RAM)…

6
6 Steps Of An Executing Program so the program can be executed by the CPU…

7
127 128 129 130 131 132 01010010 133 134...... … … 01010110 01110010 11010010 10110010 10111110 11100000 00000001 01010010 11100000 A Program in Memory Program: consists of instructions & data Instructions & data stored together in memory

8
127 128 129 130 131 132 01010010 133 134...... … … 01010110 01110010 11010010 10110010 10111110 11100000 00000001 01010010 11100000 Instructions A Program in Memory

9
127 128 129 130 131 132 01010010 133 134...... … … 01010110 01110010 11010010 10110010 10111110 11100000 00000001 01010010 11100000 A Program in Memory Instructions Data

10
127 128 129 130 131 132 01010010 133 134...... … … 01010110 01110010 11010010 10110010 10111110 11100000 00000001 01010010 11100000 A Program in Memory Instructions Data How do we interpret these 0's and 1's?

11
The Decimal Number System Deci- Base is ten first (rightmost) place:ones (i.e., 10 0 ) second place:tens (i.e., 10 1 ) third place:hundreds (i.e., 10 2 ) … Digits available: 0, 1, 2, …, 9 (ten total)

12
The Binary Number System Bi- (two) bicycle, bicentennial, biphenyl Base two first (rightmost) place:ones (i.e., 2 0 ) second place:twos (i.e., 2 1 ) third place:fours (i.e., 2 2 ) … Digits available: 0, 1 (two total)

13
Lingo Bit (b): one binary digit (0 or 1) Byte (B): eight bits Prefixes: Kilo (K)= 2 10 = 1024 Mega (M)= 2 20 = 1,048,576 = 2 10 K Giga (G)= 2 30 = 1,073,741,824 = 2 10 M Tera (T)= 2 40 = 1,099,511,627,776 = 2 10 G Peta (P)= 2 50 = 1,125,899,906,842,624 = 2 10 T … Yotta (Y)= 2 80 = 1,208,925,819,614,629,174,706,176 = 2 30 P

14
Representing Decimal in Binary Moving right to left, include a "slot" for every power of two ≤ your decimal number Then, moving left to right: Put 1 in the slot if that power of two can be subtracted from your total remaining Put 0 in the slot if not Continue until all slots are filled filling to the right with 0's as necessary

15
Example: A Famous Number Anyone recognize this number ? 100001000101111111101101

16
Example: A Famous Number Anyone recognize this number ? 8,675,309 10 = ????????????????????? 2 What is 2 10 ?

17
Example: A Famous Number Anyone recognize this number ? 8,675,309 10 = ????????????????????? 2 What is 2 10 ? 2 20 ?

18
Example: A Famous Number Anyone recognize this number ? 8,675,309 10 = ????????????????????? 2 What is 2 10 ? 2 20 ? 2 30 ?

19
Example: A Famous Number Anyone recognize this number ? 8,675,309 10 = ????????????????????? 2 What is 2 10 ? 2 20 ? 2 30 ? 2 25 ?

20
Example: A Famous Number Anyone recognize this number ? 8,675,309 10 = ????????????????????? 2 What is 2 10 ? 2 20 ? 2 30 ? 2 25 ? Need 24 places (bits) 2 23 = 8,388,608

21
To the whiteboard, Robin !

22
Example: A Famous Number Anyone recognize this number ? 8,675,309 10 = 100001000101111111101101 2 Fewer available digits in binary more space required for representation

23
Converting Binary to Decimal For each 1, add the corresponding power of two 1010010111101 2

24
Converting Binary to Decimal For each 1, add the corresponding power of two 1010010111101 2 = 5309 10

25
Now You Get The Joke THERE ARE 10 TYPES OF PEOPLE IN THE WORLD: THOSE WHO CAN COUNT IN BINARY AND THOSE WHO CAN'T

26
Why Binary? ABA xor BA and B 00 01 10 11 Circuits: low voltage == 0, high voltage == 1

27
Why Binary? ABA xor BA and B 0000 0110 1010 1101 Circuits: low voltage == 0, high voltage == 1

28
Why Binary? ABA xor BA and B 0000 0110 1010 1101 A + B sum A + B carry Circuits: low voltage == 0, high voltage == 1 Half Adder

29
An Alternative to Binary? 100001000101111111101101 2 = 8,675,309 10 100000100101111111101101 2 = 8,544,237 10

30
An Alternative to Binary? 100001000101111111101101 2 = 8,675,309 10 100000100101111111101101 2 = 8,544,237 10 What if this was km to landing?

31
The Hexadecimal Number System Hexa- (six) Decimal (ten) Base sixteen first (rightmost) place:ones (i.e., 16 0 ) second place:sixteens (i.e., 16 1 ) third place:two-hundred-fifty-sixes (i.e., 16 2 ) … Digits available: sixteen total 0, 1, 2, …, 9, A, B, C, D, E, F

32
Wikipedia says… Donald Knuth has pointed out that the etymologically correct term is "senidenary", from the Latin term for "grouped by 16". The terms "binary", "ternary" and "quaternary" are from the same Latin construction, and the etymologically correct term for "decimal" arithmetic is "denary". Schwartzman notes that the pure expectation from the form of usual Latin-type phrasing would be "sexadecimal", but then computer hackers would be tempted to shorten the word to "sex".

33
Using Hex Can convert decimal to hex and vice-versa process is similar, but using base 16 and 0-9, A-F Most commonly used as a shorthand for binary Avoid this

34
More About Binary How many different things can you represent using binary: with only one slot (i.e., one bit)? with two slots (i.e., two bits)? with three bits? with n bits?

35
More About Binary How many different things can you represent using binary: with only one slot (i.e., one bit)?2 with two slots (i.e., two bits)?2 2 = 4 with three bits?2 3 = 8 with n bits?2 n

36
Binary vs. Hex One slot in hex can be one of 16 values 0, 1, 2, …, 9, A, B, C, D, E, F How many bits to represent one hex digit? I.e., how many bits to represent 16 different things?

37
Binary vs. Hex One slot in hex can be one of 16 values 0, 1, 2, …, 9, A, B, C, D, E, F How many bits to represent one hex digit? 4 bits can represent 2 4 = 16 different values

38
Binary vs. Hex 00000 10001 20010 30011 40100 50101 60110 70111 81000 91001 A1010 B1011 C1100 D1101 E1110 F1111

39
Converting Binary to Hex Moving right to left, group into bits of four Convert each four-group to corresponding hex digit 100001000101111111101101 2

40
Converting Binary to Hex Moving right to left, group into bits of four Convert each four-group to corresponding hex digit 1000 0100 0101 1111 1110 1101 2

41
Converting Binary to Hex Moving right to left, group into bits of four Convert each four-group to corresponding hex digit 1000 0100 0101 1111 1110 1101 2 8 4 5 F E D 100001000101111111101101 2 = 845FED 16

42
Converting Hex to Binary Convert each hex digit to four-bit binary equivalent BEEF 16 = ???? 2

43
Converting Hex to Binary Convert each hex digit to four-bit binary equivalent BEEF 16 = 1011 1110 1110 1111 2

44
Representing Different Information So far, everything has been a number What about characters? Punctuation? Idea: put all the characters, punctuation in order assign a unique number to each done! (we know how to represent numbers)

45
ASCII: American Standard Code for Information Interchange

46
'A' = 65 10 = 01000001 2 'c' = 99 10 = 01100011 2 '8' = 56 10 = 00111000 2 ASCII: American Standard Code for Information Interchange

47
256 total characters… How many bits needed? ASCII: American Standard Code for Information Interchange

48
The Problem with ASCII What about Greek characters? Chinese? UNICODE: use more bits UTF-8: use 1-4 eight-bit bytes 1,112,064 “code points” backward compatible w/ ASCII How many characters could we represent w/ 32 bits? 2 32 = 4,294,967,296

49
You Control The Information What is this? 01001101

50
You Control The Information What is this? 01001101 Depends on how you interpret it: 01001101 2 = 77 10 01001101 2 = 'M' 01001101 10 = one million one thousand one hundred & one A machine-language instruction You must be clear on representation and interpretation

51
Strings… "1000" There are four characters '1' '0' '0' '0' The binary representation is 00110001 00110000 00110000 00110000 1000 10 = 1111101000 2

52
Strings… "1000" There are four characters '1' '0' '0' '0' The binary representation is 00110001 00110000 00110000 00110000 1000 10 = 1111101000 2 “1234” ≠ 1234

53
One Last Thing… Real valued (AKA floating point) numbers? Round-off error! FLOPS: Floating Point Operations Per Second

54
One Last Thing… Real valued (AKA floating point) numbers? Round-off error! FLOPS: Floating Point Operations Per Second

Similar presentations

Presentation is loading. Please wait....

OK

Connecting with Computer Science, 2e

Connecting with Computer Science, 2e

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on lost city of atlantis mystery Download ppt on bluetooth hotspot Ppt on accounting standard 12 Ppt on ready to serve beverages menu Ppt on metallic and non metallic minerals Ppt on dc motor for class 10 Ppt on health and medicine class 10 Ppt on credit default swaps news Ppt on english speaking course Ppt on non agricultural activities kenya