Operators identifiers
This presentation is the property of its rightful owner.
Sponsored Links
1 / 45

Operators & Identifiers PowerPoint PPT Presentation


  • 87 Views
  • Uploaded on
  • Presentation posted in: General

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

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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Operators identifiers

Operators & Identifiers

The Data Elements


Arithmetic operators

exponentiation

multiplication

division (real)

division (integer quotient)

division (integer remainder)

addition

Subtraction

assignment

^

*

/

\

Mod

+

-

=

Arithmetic Operators


Evaluate these expressions

Evaluate these expressions


Evaluate these expressions1

Evaluate these expressions


Evaluate these expressions2

Evaluate these expressions


Evaluate these expressions3

Evaluate these expressions


Evaluate these expressions4

Evaluate these expressions


Evaluate these expressions5

Evaluate these expressions


Variables

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.


Variable names in vb

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


Variables1

Variables

  • Local

    • Declared within a subprogram

    • Dim varName As dataType

  • Global

    • Declared at the top of the code listing

    • Private varName As dataType


Data types

Data Types


The ascii character set

The ASCII Character Set


Data storage short type

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


Data storage 2nd byte

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?


Integer storage

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?


2 s complement notation examples in 8 bits to save space

2’s Complement Notation(examples in 8 bits to save space)

  • The notation system that uses 1 to represent negative values.

  • Fixed length notation system.

  • Zero is the first non-negative value:

    00000000

  • The pattern immediately before zero is -1

    11111111

  • The largest value is stored as 01111111

  • The smallest value is stored as 10000000


Arithmetic in 2 s complement remember it s a fixed length system

Arithmetic in 2’s Complement(remember it’s a fixed length system)

00 + 00 = 00

00 + 01 = 01

01 + 00 = 01

01 + 01 = 10


Integer storage 4 bytes

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


  • Long integers

    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


    Fractions

    Fractions

    • A radix separates the integer part from the fraction part of a number.

      101.101

    • Columns to the right of the radix have negative powers of 2.


    Fractions1

    Fractions


    Fractions2

    Fractions


    Fractions3

    Fractions


    Fractions4

    Fractions


    Fractions5

    Fractions


    Scientific notation

    Scientific Notation

    Very large and very small numbers are often represented such that their order of magnitude can be compared.

    The basic concept is an exponential notation using powers of 10.

    a × 10b

    Where b is an integer, and a is a real number such that:

    1 ≤ |a| < 10


    Scientific notation1

    Scientific Notation

    An electron's mass is about

    0.00000000000000000000000000000091093826 kg.

    In scientific notation, this is written

    9.1093826×10−31 kg.

    The Earth's mass is about

    5,973,600,000,000,000,000,000,000 kg.

    In scientific notation, this is written

    5.9736×1024 kg.


    E notation

    E Notation

    To allow values like this to be expressed on calculators and early terminals

    × 10b

    was replaced by Eb

    So 9.1093826×10−31

    becomes 9.1093826E−31

    And 5.9736×1024

    becomes 5.9736E+24


    E notation1

    E Notation

    The ‘a’ part of the number is called the mantissa or significand.

    The ‘Eb’ part is called the exponent.

    Since these numbers could also be negative they would typically have a sign as well.


    Floating point storage

    Floating Point Storage

    In floating point notation the bit pattern is divided into 3 components:

    Sign– 1 bit (0 for +, 1 for -)

    Exponent– stored in Excess notation

    Mantissa– must begin with 1


    Excess notation examples are in 8 bits to save space

    Excess Notation(examples are in 8 bits to save space)

    • The notation system that uses 0 to represent negative values.

    • Fixed length notation system.

    • Zero is the first non-negative value:

      • 10000000

    • The pattern immediately before zero is -1

      • 01111111

    • The largest value is stored as 11111111

    • The smallest value is stored as 00000000


    Mantissa

    Mantissa

    • Assumes a radix point immediately left of the first digit.

    • The exponent will determine how far and in which direction to move the radix.


    An example in 8 bits

    An example in 8 bits

    If the following pattern stores a floating point value, what is it?

    01101001


    An example in 8 bits1

    An example in 8 bits

    If the following pattern stores a floating point value, what is it?

    01101001

    Separate it into its components:


    An example in 8 bits2

    An example in 8 bits

    If the following pattern stores a floating point value, what is it?

    01101001

    Separate it into its components:signexponentmantissa


    An example in 8 bits3

    An example in 8 bits

    If the following pattern stores a floating point value, what is it?

    01101001

    Separate it into its components:signexponentmantissa


    An example in 8 bits4

    An example in 8 bits

    01101001

    A sign bit of 0 means the number is…?


    An example in 8 bits5

    An example in 8 bits

    01101001

    A sign bit of 0 means the number is positive.

    110 in Excess Notation converts to …?


    An example in 8 bits6

    An example in 8 bits

    01101001

    A sign bit of 0 means the number is positive.

    110 in Excess Notation converts to +2.

    Place the radix in the mantissa …


    An example in 8 bits7

    An example in 8 bits

    01101001

    A sign bit of 0 means the number is positive.

    110 in Excess Notation converts to +2.

    Place the radix in the mantissa .1001

    Put it all together …


    An example in 8 bits8

    An example in 8 bits

    01101001

    A sign bit of 0 means the number is positive.

    110 in Excess Notation converts to +2.

    Place the radix in the mantissa .1001

    Put it all together …

    +.1001 * 22


    An example in 8 bits9

    An example in 8 bits

    +.1001 * 22

    Multiplying a binary number by 2 shifts the bits left (move the radix to the right) one position.

    So the exponent tells us to shift the radix 2 positions right.

    +10.01

    = 2¼


    Normal form

    Normal Form

    • The first bit of the mantissa must be 1 to prevent multiple representations of the same value.


    Data type conversion

    Data Type Conversion


  • Login