Storing non-numerical information inside a computer

 

  • Computers can only store binary numbers in its memory (because computer memory is made up of electrical switches that can be either ON or OFF):

  • $64,000 question:

    • How can a computer store (non-numerical) of information ???

Storing non-numerical information inside a computer

Demistifying the computer system:

  • Computer memory can only store binary numbers

  • How then can a computer store (non-numerical) information (like letters) ???

Answer:

  • We use codes (i.e.: agreement) !!!

    Example:

        01000001  represents the letter 'A'      
        01000010  represents the letter 'B'
        01000011  represents the letter 'C'
        etc
      

Code and encoding scheme

Codes:

  • What is a code:

      • A code is an agreement on how information is represented

    (When you were a kid, you may have designed a secret code with your friends to exchange messages)

  • There are many different codes used in the computer to represent different kinds of information.

    Examples of codes used in the computer:

      • There is a code (called "2's complement code") to represent integer numbers
      • There is a code (called "ASCII code") to represent characters in text
      • There is a IEEE 754 code to represent floating point numbers
      • There is a 0/not-0 code to represent boolean values

Example of a code used in a computer program: code for Boolean values
 

  • Many programming languages (including C and Python) uses the following code to represent Boolean values:

         Binary number    Boolean value represented
        ---------------  ---------------------------   
         0000000                false
         not 0000000            true
      

 

 

DEMO: /home/cs255001/demo/data-type/boolean-code.c
DEMO: /home/cs255001/demo/data-type/boolean.py   (python3 boolean.py)