Problem Statement

How to store (your own) non-numerical information
 

Principle of representing (non-numerical) information:

How to store (your own) non-numerical information - Examples
 

Example: representing the "gender" information

 

Example: representing the "marital status" information

Information = Code + Context
 

The importance of the context used to decipher a code

What is the sex and marital status of each person ???

Without the context, we cannot decode the code value 0 (or 1) !!!

Information = Code + Context
 

The importance of the context used to decipher a code

What is the sex and marital status of each person ???

With the correct context, we can decode the code value 0 (or 1) !!!

Example: context of usage of "You"

(Don't use the word "You" as a personal pronounce....)

How do computer programs store information
 

(Try print the variables out in a Java program !!!)

Encoding methods used by program data types
 

Encoding method used by some commonly used data types:

  • char type in C: ASCII code
    char type in Java: Unicode

  • int: 32 bit 2's complement code        

  • float: 32 bit IEEE 754 code
 

We will learned more about the different encoding method later in the course

How to store gender and marital status information ?
 

Possible solution:

   public class Person
   {
      String name;

      // Variable reserved for gender info
      int    gender;     
    
      // Variable reserved for mari stat info   
      int    maritalStatus;  
      ...
   }