CSCI 1300
Lecture Notes


9/23/97

Administrative Stuff 



Administrative Stuff

  • I will be at a conference from 9/24 - 10/1. Prof. Karl Winklmann will teach the class in my place.
  • Results of programming assignment #2
  • Results of Quiz #1.
  • Quiz #2 - Tuesday Oct. 7
  • Programming assignment #5 due Oct. 3
  • Programming assignment #6 due Oct. 10


  • Memory Organization

    Physical memory
  • The hardware elements that are used for almost all computer memory have exactly two states - low voltage and high voltage.
  • Each element of memory is used to represent one binary digit of information, called a bit.
  • We say that the low state represents the value 0 and the high state represents the value 1.
  • The bits are organized physically into words. The number of bits in a word is dependent upon the details of the hardware, but is usually 16 or 32.
  • Physical memory is essentially one big list of words. The address of a particular memory location is just it's position in the list.
  • Words are broken into 8 bit logical elements called bytes.


  • Number systems


    Decimal numbers - base 10

  • Decimal numbers use 10 digits (0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
  • The position of a digit in a number indicates the power of 10 that it is multiplied by.
  • Example:
  • 125 = (1 * 100) + (2 * 10) + (5 * 1)

    but 100 is 10^2, 10 is 10^1, and 1 is 10^0

    So 125 = (1 * 10^2) + (2*10^1) + (5 * 10^0)

  • Note that this is the same as ((((1 * 10) + 2) * 10) + 5)

  • Binary numbers - base 2

  • Binary numbers work the same way as decimal numbers, but have only two digits (0 and 1).
  • Binary numbers are a natural representation for computers because of the two-state memory elements.
  • Example:
  • >p>
    10b = (1 * 2^1) + (0 * 2^0) = 2 + 0 = 2

    1101b = (1 * 2^3) + (1 * 2^2) + (0 * 2^1) + (1 * 2^0) = 8 + 4 + 0 + 1 = 13

    Equivalent to ((((((1 * 2) + 1) * 2) + 0) * 2) + 1)

  • Adding binary numbers: 01001011 + 10001101 = 11011000
  • How many bits does it take to store this number?

  • Hexadecimal numbers - base 16

  • Hexadecimal numbers use 16 digits (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F)
  • Natural for computers since 4 bits = one hex digit
  • Example:

  • 4A7h = (4 * 16^2) + (10 * 16^1) + (7 * 16^0) = 1024 + 160 + 7 = 1191

    Equivalent to ((((4 * 16) + 10) * 16) + 7)

  • Adding hex numbers: 4A7 + BE0 = 1087h = 4231d
  • How many bits does it take to store this number?

  • Octal numbers - base 8

  • Octal numbers use 8 digits (0, 1, 2, 3, 4, 5, 6, 7, 8)
  • 3 bits = one octal digit
  • Example:

  • 235o = (2 * 8^2) + (3 * 8^1) + (5 * 8^0) = 128 + 24 + 5 = 157

  • How many bits does it take to store this number?
  •  



    Data Storage

    Computer memory is all bits.

    In our systems, each word is 32 bits long

    That means that in one word we can store any number between 0 and 2^32 - 1 = 4294967295

    Bit operations: shifting, masking

    In Borland C++,
  • A char is  1 byte = 8 bits
  • A short is 2 bytes = 16 bits
  • An int is   4 bytes = 32 bits
  • A long is  4 bytes = 32 bits