1 / 5

Basic Data Types

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).

atrujillo
Download Presentation

Basic Data Types

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 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

  2. 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

  3. 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

  4. 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)

  5. 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

More Related