The principle of information representation inside the computer:
|
I will show you some examples on how to represent information next
Example: how to represent "sex" information
|
Note: this is an example of the use of codes to present information !!!
Example: how to represent "marital status" information
|
Note:
I used decimal number
(0,1,2,3) for
simplicity.
Computers will use
binary numbers:
00, 01, 10 and
11
An example to illustrate the importance of the context:
|
An example to illustrate the importance of the context:
|
No: we no not have the context needed to interpret the code ( 0 and 1)
Suppose we are also given the context to interpret the data:
|
We can now interpret the code:
|
Person A is married (1) and a male (0) !!!
|
A Java program that shows that the data type contains the context to interpret the code 65:
public class Context
{
public static void main(String[] args)
{
int x; // The code represents a number
char y; // The code represents a character
x = 65;
System.out.println(x); // Prints "65" (read it "directly" as a number)
y = 65;
System.out.println(y); // Prints "A" (ASCII code 65 is 'A'
}
}
|
(The Java compiler will
call a
different
println( ) method
based on the
data type of the
input parameter)
See:
click here
DEMO: /home/cs255001/demo/data-type/Context.java
ASCII code table: https://www.ascii-code.com/
Question:
|
Question:
|
The word You is normally used in the context of a personal pronounce
The solution is to use the word You in the context of a noun !!