Presentation is loading. Please wait.

Presentation is loading. Please wait.

Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.

Similar presentations


Presentation on theme: "Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division."— Presentation transcript:

1 Operators & Identifiers The Data Elements

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

3 Evaluate these expressions = 100 / 10 / 5 = 100 / 10 \ 5 = 100 \ 10 / 5 = 100 + 10 Mod 5 = 100 + 10 \ 5

4 Evaluate these expressions = 100 / 10 / 52 = 100 / 10 \ 5 = 100 \ 10 / 5 = 100 + 10 Mod 5 = 100 + 10 \ 5

5 Evaluate these expressions = 100 / 10 / 52 = 100 / 10 \ 52 = 100 \ 10 / 5 = 100 + 10 Mod 5 = 100 + 10 \ 5

6 Evaluate these expressions = 100 / 10 / 52 = 100 / 10 \ 52 = 100 \ 10 / 550 = 100 + 10 Mod 5 = 100 + 10 \ 5

7 Evaluate these expressions = 100 / 10 / 52 = 100 / 10 \ 52 = 100 \ 10 / 550 = 100 + 10 Mod 5100 = 100 + 10 \ 5

8 Evaluate these expressions = 100 / 10 / 52 = 100 / 10 \ 52 = 100 \ 10 / 550 = 100 + 10 Mod 5100 = 100 + 10 \ 5102

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 (procedure-level) –Declared within a subprogram –Dim varName As dataType Global (module-level) –Declared at the top of the code listing –Private varName As dataType

12 Data Types Boolean2 bytesTrue or False (1 or 0) Char2 bytes0 to 65,535 representing the Unicode character set Date8 bytes0:00:00 on 1/1/0001 to 23:59:59 on 31/12/9999 Decimal16 bytes +/- 79,228,162,514,264,337,593,543,950,335 +/- 7.9228162514264337593543950335 Double8 bytes +/-4.94065645841247 X 10 -324 to +/-1.79769313486231 X10 308 Integer4 bytes-2,147,483,648 to 2,147,483,647 Long8 bytes -9,223,382,036,854,775,808 to 9,223,382,036,854,775,807 Object4 bytesany type Short2 bytes-32,768 to 32,767 Single4 bytes+/- 1.401298 X 10 -45 to +/- 3.402823 X 10 38 String0 to approximately 2 billion characters

13 The ASCII Character Set

14 Data Storage (Short type) 2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 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) 2 15 2 14 2 13 2 12 2 11 2 10 2 9 2 8 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 Short Integers 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 2 31 The number of different combinations =2 32 =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 2 63. The number of different combinations =2 64 =18,446,744,073,709,650,616 Ranging from -9,223,382,036,854,775,808 to 9,223,382,036,854,775,807

19 Data Type Conversion


Download ppt "Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division."

Similar presentations


Ads by Google