1 / 19

Operators & Identifiers

Operators & Identifiers. The Data Elements. exponentiation multiplication division ( real ) division ( integer quotient ) division ( integer remainder ) addition Subtraction assignment. ^ * / Mod + - =. Arithmetic Operators. Evaluate these expressions.

denise
Download Presentation

Operators & Identifiers

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. Operators & Identifiers The Data Elements

  2. exponentiation multiplication division (real) division (integer quotient) division (integer remainder) addition Subtraction assignment ^ * / \ Mod + - = Arithmetic Operators

  3. Evaluate these expressions

  4. Evaluate these expressions

  5. Evaluate these expressions

  6. Evaluate these expressions

  7. Evaluate these expressions

  8. Evaluate these expressions

  9. Variables • A variable is a string used to identify a memory location. • The amount of memory is determined by the type of data that it will store. • Typically, variable names need to be declared so the operating system can allocate sufficient space. • Then values of the specified type can be assigned, i.e. stored in that location.

  10. Variable Names in VB • Must begin with a letter • Can include letters and numerals • Cannot include spaces • Use names that are descriptive • Capitalising convention • InterestRate, InitialCapital

  11. Variables • Local • Declared within a subprogram • Dim varName As dataType • Global • Declared at the top of the code listing • Private varName As dataType

  12. Data Types

  13. The ASCII Character Set

  14. Data Storage (Short type) 27 26 25 24 23 22 21 20 128 64 32 16 8 4 2 1 1 1 1 1 1 1 1 1 128 +64 +32 +16 +8 +4 + 2 + 1 =255

  15. Data Storage (2nd byte) 215 214 213 212 211 210 29 28 32768 16384 8192 4096 2048 1024 512 256 1 1 1 1 1 1 1 1 32768+16384 +8192 +4096 +2048 +1024 +512 +256 =65280 +255 65535 The largest Unsigned value that can be stored in 16 bits. How many patterns are there?

  16. Integer Storage • To store integers, half the combinations are used to represent negative values. • The range for Integer type variables is: -32,768 to +32767 • The MSB is used to represent the sign. • Which value of the sign bit (0 or 1) will represent a negative number?

  17. Integer Storage (4 bytes) • High order bit (MSB) is worth 231 • The number of different combinations • 232 • 4,294,967,296 • Half are used for negative values, so the range is • 2,147,483,648 to + 2,147,483,647

  18. Long Integers • In 8 bytes there are 64 bits! • High order bit (MSB) is worth 263. • The number of different combinations • 264 • 18,446,744,073,709,650,616

  19. Data Type Conversion

More Related