Lecture 3: Units of Information /  Memory



As described in the previous lesson, the memory is an essential part of the computer. It stores
Note: The idea to seperate the program form the data it is working on and to seperate the hardware from the software (or the "the machine" and the "program") comes from Von Neumann. He designed the first electronic computer capable of running a flexible program (1940-1952). All modern computers are Von Neumann computers.
The on-line encyclopaedia Wikipedia has more about Von Neumann (or other subjects).

Before writing programs, it is useful to take a closer look at the memory.

Memory is filled with information. This information can either be program code or data. Let's take a look at some types of information.


BIT

The smallest unit of information is a bit. One bit can contain inforamtion of the type "TRUE or FALSE". For example, it can contain the information
  "Did the student pay his tuition fees (propinas), yes or no?",
  "Can the student go to the frequencia, yes or no?",
  "Is x larger than y?".
We have to remember that, at the electronics level, the computer is calculating with these bits of information. In the previous lecture we have seen how digital electronic components ("AND gates", etc.) handle these bits of information. For these electronic components, there are two levels: 0 V and +5 V (or any pair of discrete voltage levels). In our language, we can call it 'TRUE' and 'FALSE', or '1'  and '0', or 'green' and 'red', or whatever pair of symbolic names we want to give it.
Because a bit of information can be only one of two possible values, we call it a binary unit. Since all units of inforamtion are derived from these bits, we call a computer a binary calculator. Although computers can easily be constructed using other basic untis of information (for instance ternary or quaternary), all modern computers are of the type binary calculators.
 
electronic levels
of AND gates
0 V +5 V
binary 0 1
logical FALSE TRUE
bicolor green red

These ideas can be mixed at our wish. For example, PASCAL uses the ideas 'TRUE' and 'FALSE' for logical calculations, while C uses '1' and '0'.


NIBBLE

The next unit of information is a nibble. This is a set of 4 bits. In these 4 bits we can for instance store information of the type 0..9. Nibbles are therefore used in many digital displays, such as alarm clocks etc, where each digit is stored in a nibble. We call this binary-coded-decimal (BCD):
 binary 
 BCD 
0000
0
0001
1
0010
2
0011
3
0100
4
0101
5
0110
6
0111
 binary 
BCD
1000
8
1001
9
1010
 not used 
1011
 not used 
1100
 not used 
1101
 not used 
1110
 not used 
1111
 not used 

                 example of an LED display

Looking at the table we see that when the binary code is
       abcd
the decimal code is
      a*8  +  b*4  +  c*2  +  d
or, more general:
      a*23  + b*22  +  c*2  +  d
This, we will see, is always the relation between binary and decimal numbers.

Note also that some of the possible combinations of bits are not used in BCD. A way to represent these four bits of information with all possbile combinations used is the hexadecimal system. The bit combinations from '1010' to '1111' are then represented by the letters A to F. In a hexadecinal representation we get the following translation table:
 

 binary 
hexa-
 decimal 
0000
0
0001
1
0010
2
0011
3
0100
4
0101
5
0110
6
0111
7
 binary 
hexa-
 decimal 
1000
8
1001
9
1010
A
1011
B
1100
C
1101
D
1110
E
1111
F
and we see that all 16 binary combinations have a counterpart in the hexadecimal system The hexadecimal system is widely used in computer technology.
As an example: 21F in the hexadecimal system is equal to 2*162 + 1*161 + 15*160 = 2*256 + 1*16 + 15*1 = 543.
 

BYTE

The next unit of information is a byte. A byte is a combination of two nibbles and thus of 8 bits. In this we can store numbers from 0..255 because
 
 
00000000 = 0*27 + 0*26 + 0*25 + 0*24 + 0*23 + 0*22 + 0*21 + 0*20 = 0 

11111111 = 1*27 + 1*26 + 1*25 + 1*24 + 1*23 + 1*22 + 1*21 + 1*20
                 = 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 =
                 = 255 

another example:
11011001 = 1*27 + 1*26 + 0*25 + 1*24 + 1*23 + 0*22 + 0*21 + 1*20
                 = 128 + 64 + 0 + 16 + 8 + 0 + 0 + 1 =
                 = 217

Alternatively, a byte can represent all the letters of the alphabet, in uppercase ('A' .. 'Z') and lowercase ('a' .. 'z'), plus all the digits '0' .. '9', some special letters like '{',  '}',  '(', ')', space, etc, and other things like control codes. The most often used way to do this is ASCII (American Standard Code of Information Interchange) in which, for example 'A' is 65 (decimal), or 01000001 (binary), or 41 (hexadecimal). Other examples are:
 

binary
 decimal 
 hexadecimal 
 ASCII 
 01000001 
65
41
'A'
 01000010 
66
42
'B'
 01100001 
97
61
'a'
 00010000 
32
20
' '


Memory

In many computers, the byte is the smallest unit that can be 'addressed'. To understand this idea, we have to look at how the memory is organized. Imagine the memory as a (very long) street with houses. Each house has an address. If we want to put something in a house or take something out of it, we have to specify the address of the house.
In a computer, the memory takes the place of the street and the byte takes the place of the house. In each 'house' live 8 bits, or a byte.

As we will se later,  some 'people' (units) are very big and occupy two or even more adjacent houses. These 'people' are called 'integers', 'words', 'reals', etc. Still, addresses are in most computers 1 byte and thus 8 bits apart.
(Note [not needed to study]: especially in supercomputers the distance between two addresses can be much longer than a byte, for example 63 bits instead of 8. We call this distance the 'word length' of a computer.)

Note that all three units described until now are also units of food in English. Bit, Nibble, Byte. Further units disband this idea.


Memory Size of Computers

 Very often you read in the advertisement things like:
     Computer, with 1.7 GHz processor,  256 MB RAM, 40 GB harddisk, 1.4 MB floppy 

The 1.7 GHz specifies the speed of the CPU (the central processing unit). 1.7 GHz thus means that it can do 1.7 million simple instructions per second.
(Since most commands given to the processor take more than one simple instruction, the actual number of commands per second is lower. For example an addition of two floating point number might consist of 1) loading the first number from memory, 2) loading the second number from memory, 3) adding the number (possibly in several steps), 4) saving the result to memory. Nevertheless, the overall speed of a computer is largely determined by the speed of the processor and the speed with which it can load the data from memory.)

The other numbers determine the size of the memory of the computer (RAM = Random-access memory), the harddisk and the floppy disk repectively, in number of bytes (B). To give an idea what these numbers mean, let's analyze them more carefully:

BYTE: The basic unit to describe memory is the byte (B). As said before, a byte is large enough to contain a single letter, or a number from 0 .. 255.

KILOBYTE: 1024 bytes is called a kilobyte (kB). In science, 'kilo' means exactly 1000, a nice round number in the decimal system. For computers 'kilo' means a little more, 1024. This is based on the fact that 1024 is exactly 210, or in binary 10000000000, a nice round number.
To give an idea of how much a kilobyte is: A page of A4 with text is approximately 4 kB.
 
 
MEGABYTE: 1024 kilobytes is a megabyte (MB). This is then equal to 1024 x 1024 bytes, or 1048476 bytes.
To give an idea how much a megabyte is: 250 pages of text, or, let's say a book.
Most floppies are 1.4 MB and this is thus enough to store a book of about 350 pages.
(without images etc.)

 
GIGABYTE: 1024 megabytes is a gigabyte (GB).
This is enough to store a nice library of a thousand books.
Most CD-ROMs have 650 MB (0.65 GB), enough to store a small library

 
Modern harddisks have about 40 GB space. On this we can therefore store a large library, some 40.000 books.

TERABYTE: 1024 gigabytes is a terabyte. Although disks of this size do not exist yet, some companies have computer systems with many disks totalling disk space in the order of terabytes. This is enough to store all the books in the world.
 
 
To give an idea about the total amount of diskspace on the world: there exist about 500 million computer owners in the world. On the average, each has a hardisk of about 10 GB. That makes a total of approximately 5.000.000.000.000.000.000 bytes. It would take a person reading 10 books per day more than a billion years to complete reading all the information!


Quick test:

To test your knowledge of what you have learned in this lesson, click here for an on-line test. Note that this NOT the form the final test takes!


Peter Stallinga, Universidade do Algarve, 13 fevereiro 2002