1 / 12

Mid Term

Mid Term. Topics. Data Representation - Number system conversion (conversions between different bases but not 2's compliment) b . Data Types and operations (Signed and Unsigned numbers also) c . Variables and constants d . String operations e . Conditionals - Selection (if/else, switch)

ivory-bauer
Télécharger la présentation

Mid Term

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. Mid Term

  2. Topics • Data Representation - Number system conversion (conversions between different bases but not 2's compliment) • b. Data Types and operations (Signed and Unsigned numbers also) • c. Variables and constants • d. String operations • e. Conditionals - Selection (if/else, switch) • f. Loops (for , while, do-while) (no do-while tested explicitly) • g. Writing static methods with input parameters and return values

  3. Data Representations

  4. Data Representations • Data comes in many types • int, double, String, float, boolean, char • The smallest addressable data is a byte • A byte is 8 bits where each bit is a 0 or 1 • integers are stored as 4 bytes • For example if we say : • int x = 10; /* we see the following byte pattern */

  5. Data Representations ctd.. • For example if we say : • int x = 259; /* we see the following byte pattern */ • Write the bit pattern for • int x = 520;

  6. Hexadecimals • For convenience we can represent bit patterns in data storages using other formats • One such format is hexadecimal • Hexadecimal uses 16 digits (base 16): 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F • Each hexadecimal digit is represented by 4-bits

  7. Hexadecimals continued • Write the following integer using hexadecimal notation

  8. Octal • For convenience we can represent bit patterns in data storages using other formats • Another format is octal • Octal uses 8 digits (base 8): 0,1,2,3,4,5,6,7 • Each octal digit is represented by 3-bits

  9. Octals continued • Write the following integer using octal notation. • Hint: group the bits by 3’s (from right to left)

  10. Variables

  11. A variable is a container A container that can hold a byte (byte) A container that can hold 2 bytes (short or char) A container that can hold 4 bytes (int) A container that can hold 8 bytes (double)

  12. Initializing variables and changing X 10 int x = 10; x = x + 5; x = x + 20; X 15 X 35

More Related