50 likes | 64 Views
The Data Type Character. And Now …. Back to Characters. Basic Data Types. So far, we know the following :. A character is requires 8-bits (1-byte) of storage. The standard ASCII character set consists of 128 characters (7-bits needed).
E N D
The Data Type Character And Now …. Back to Characters. Basic Data Types So far, we know the following: • A character is requires 8-bits (1-byte) of storage • The standard ASCII character set consists of 128 • characters (7-bits needed) • The Extended ASCII consists of 256 Characters (8-bits) • Characters are, in fact, stored as Numbers: The character ‘0’ is stored as the numeric value 48 The character ‘a’ is stored as the numeric value 97 The character ‘A’ is stored as the numeric value 65 The character ‘ ‘ (space) is stored as the numeric value 32 The character ESC (escape) is stored as the numeric value 27 The character BEL (bell) is stored as the numeric value 7 The character BS (backspace) is stored as the numeric value 8 The character CR (return) is stored as the numeric value 13 The character NUL (null) is stored as the numeric value 0
In C, when we make the declaration: Basic Data Types chara; We are: • Requesting that 1-byte of RAM be allocated • (by using the reserved word char) • Indicating that whenever we use the variable a, we are • referring to a specific location in memory • (which will be established at run-time) If we were to make the declaration: chara = ‘A’; We would also be requesting: • That the numeric value 65 (10000012) be stored at location a
We could have also made the initialization: Basic Data Types chara=65; Which would have exactly the same effect as: chara=‘A’; Within the program (after initialization) we could have made the statement(s): a= ‘m’; OR a = 109; Both of which (might) store the numeric value 109 in location a
But, if we request only 1-byte of storage doesn’t that mean that we can only store the numbers 0 through 255 (since 28 = 256 pieces of information)?? Basic Data Types Basically, Yes. Then how can we store larger numbers?? We need to increase the number of bits. By how many?? Since RAM is accessed in groups of 8-bits (1-byte), it would make sense to add-on 8-bits and store a number on 16-bits (2-bytes)
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