Basic Data Types Page 1 Characters vs Numbers
Basic Data Types Page 1 Characters vs. Numbers Adding in Binary: There are only four (4) possible combinations: 0 0 1 1 + 0 + 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). Data Structures in C for Non-Computer Science Majors Kirs and Pflughoeft
Basic Data Types Page 2 Some additional Examples of adding in Binary: 1 101 11 1 + 10 + 1 0 1 1 0 0 1 1 1 0 1 1 + 1 0 0 1 1 0 1 1 0 Data Structures in C for Non-Computer Science Majors Kirs and Pflughoeft
Basic Data Types Page 3 From the ASCII Tables, we know: 0110011 0110100 is the sequence of bits needed to represent ‘ 3’ 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? ? Data Structures in C for Non-Computer Science Majors Kirs and Pflughoeft
Basic Data Types Page 4 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-3 H 9” (License Plate Number? ? ). Trying to add the characters ‘ 3’ and ‘ 4’ makes no more sense than trying to add the strings : Yielding: How Now Brown Cow? + To be or not to be. Good Golly, Miss Molly Data Structures in C for Non-Computer Science Majors Kirs and Pflughoeft
Basic Data Types Page 5 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: The character ‘ 4’ is actually the numeric value: 51 52 The character ‘g’ is actually the numeric value: 103 Check your ASCII Tables Data Structures in C for Non-Computer Science Majors Kirs and Pflughoeft
Basic Data Types Page 6 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. Data Structures in C for Non-Computer Science Majors Kirs and Pflughoeft
Page 7 This Concludes The Slides for this Section Choose an Option: Repeat Slides for this Section Go To Next Set of Slides For this Chapter Go To Slide Index For Chapter 2 Go To Slide Index For Chapter 3 Go To Slide Index For Textbook Go To Home Page Data Structures in C for Non-Computer Science Majors Kirs and Pflughoeft
- Slides: 7