Let's discuss some basics:
- Suppose your hard drive is nothing more than an aluminum plate in a round shape and has tiny holes / spots all over (you can only see with a microscope). Spot is a small hole, grouped by bytes - 8 bits (1 bit - 1 hole).
- RAM is like a hard drive, but it is a silicon semiconductor, so it can store information in the form of an electric field and has an address for each byte, so it is faster.
- The computer stores all the information that you enter from the keyboard on the hard drive, like magnetic impulses (representing 1 for human understanding), called 1. If there is no information, then the spot (small hole) is empty is called zero.
Let's discuss your first part of your question. Could you show me some examples? For example, how does a computer translate the letter โAโ into binary?
- For example, you enter the characters "A" and "เฎ
" from the keyboard.
- The character "A" is represented as 65 in Unicode / ASCII, which is 01000001 in the binary base of base 2. OS makes the mapping of A to binary. This โAโ symbol you entered is now stored on the hard drive as 01000001 and will be displayed at 8 different points (for example, no magnetic pulse for most residues 0, magnetic pulse for 7 in the seventh digit, etc.).
- In the case of RAM, it stores information in the form of electrical pulses, and, therefore, RAM loses all information when the power is turned off.
Now all that you see in RAM or HardDrive is energy or energy in a given byte, and we call it a binary format for human understanding (let's call it 0 without energy and 1 for energy).
Now it depends on the compiler how to store it. If it is a C compiler on an AMD processor / Windows OS, it stores a value of 2 bytes (one byte for 5 and one byte for 6). A byte storing the value 5 will be on the right side of 6, if this is AMD processing - it is called low endian. C does not support the "เฎ
" character, since it takes more than 1 byte to store international characters.
If it is a Java compiler, it uses a variable length of 4 bytes called UTF-16. In the case of the letter โAโ, it requires 1 byte, since the Unicode / ASCII representation is 65. If you save an international language such as โเฎ
โ (similar to A in Tamil), then the corresponding Unicode value is 2949 and the corresponding binary value is 11100000 10101110 10000101 (3 bytes). Java has no problem storing and reading "A" and "เฎ
".
Now imagine that you saved the โเฎ
โ character on your hard drive using the Java / Windows / AMD processor as the character type (Char).
Now imagine that you want to read this using a C program like Char. The C compiler only supports ASCII, but not a complete Unicode list. Here C will read the right (10000101) byte of 3 bytes (for type char it reads 1 byte), what do you get on the screen? Your C program will read this 1 byte without any problems and draw it on your screen if you asked your program to print. Thus, the compiler is the developer of the difference.
**** Let's discuss your second part of your question: ** * And when computers see binary code, how can they know if this long string of 0s and 1s is a number or a word or instruction? ** *
Now loading your compiled Java program into RAM in the area of โโtext and data (RAM is divided into the area of โโtext and data at a high level). Now you ask that the processor ALU is executing a set of instructions from your program called Process.
A line in your compiled program is an instruction for moving data from one variable to another.
When the ALU executes the first command, it goes into the corresponding registers sitting outside, if RAM. The processor has a set of registers for data and a set of register registers. ALU now knows which register is for what, based on the fact that it executes your instruction.
Hope this helps.