Presentation is loading. Please wait.

Presentation is loading. Please wait.

Page 1 Data Structures in C for Non-Computer Science Majors Kirs and Pflughoeft Basic Data Types Characters vs. Numbers Adding in Binary: There are only.

Similar presentations


Presentation on theme: "Page 1 Data Structures in C for Non-Computer Science Majors Kirs and Pflughoeft Basic Data Types Characters vs. Numbers Adding in Binary: There are only."— Presentation transcript:

1

2 Page 1 Data Structures in C for Non-Computer Science Majors Kirs and Pflughoeft Basic Data Types Characters vs. Numbers Adding in Binary: There are only four (4) possible combinations: 0 +0 0 +1 1 +0 1 +1 10 Remember: Since binary contains the only the digits 0 & 1, the number 2 must be represented using 2 digits (10) Similarly, in Decimal, there is no symbol for ten, so we must use two symbols: 1 and 0 (10).

3 Page 2 Data Structures in C for Non-Computer Science Majors Kirs and Pflughoeft Basic Data Types Some additional Examples of adding in Binary: 1 0 1 + 1 0 1 1 1 1 1 1 + 1 0 1 0 1 1 1 1 1 1 + 1 0 1 0 0 1 1 1 1 1 1 1 1 1 1 1 0 1 0 1 1 + 1 0 0 1 1 0 + 1 0 0 1 1 0 1 1 0 1 0 1 1 1 1 0

4 Page 3 Data Structures in C for Non-Computer Science Majors Kirs and Pflughoeft Basic Data Types From the ASCII Tables, we know: 0110011 is the sequence of bits needed to represent ‘3’ 0110100 is the sequence of bits needed to represent ‘4’ Therefore: 0110011 + 0110100 1100111 Must be the sequence of bits needed to represent ‘7’ According to the ASCII Tables 1100111 is the sequence of bits needed to represent the character ‘g’. What Gives??

5 Page 4 Data Structures in C for Non-Computer Science Majors Kirs and Pflughoeft Basic Data Types ASCII is a coding to scheme used to represent ONLY CHARACTERS AND/OR SYMBOLS. The character ‘3’ is no more a number than it is in the string “TJF-3H9” (License Plate Number??). Trying to add the characters ‘3’ and ‘4’ makes no more sense than trying to add the strings : How Now Brown Cow? + To be or not to be. Yielding: Good Golly, Miss Molly

6 Page 5 Data Structures in C for Non-Computer Science Majors Kirs and Pflughoeft Basic Data Types Does that mean the computer really doesn’t work with numbers, only symbols?? NO - The computer works ONLY with numeric values: The character ‘3’ is actually the numeric value: 51 The character ‘4’ is actually the numeric value: 52 The character ‘g’ is actually the numeric value: 103 Check your ASCII Tables

7 Page 6 Data Structures in C for Non-Computer Science Majors Kirs and Pflughoeft Basic Data Types Why are there differences?? Why isn’t the character ‘3’ stored the same way as the number 3??? In order to draw the distinction between Numbers and Characters. How would the numbers 3 and 4 be stored? Basically, in the same manner in which we stored them when we first started talking about bits.

8 Page 7 Data Structures in C for Non-Computer Science Majors Kirs and Pflughoeft  Repeat Slides for this SectionRepeat Slides for this Section  Go To Next Set of Slides For this ChapterGo To Next Set of Slides For this Chapter  Go To Slide Index For Chapter 2Go To Slide Index For Chapter 2  Go To Slide Index For Chapter 3Go To Slide Index For Chapter 3  Go To Slide Index For TextbookGo To Slide Index For Textbook  Go To Home PageGo To Home Page This Concludes The Slides for this Section Choose an Option:


Download ppt "Page 1 Data Structures in C for Non-Computer Science Majors Kirs and Pflughoeft Basic Data Types Characters vs. Numbers Adding in Binary: There are only."

Similar presentations


Ads by Google