I know the jist of binary, but something that I have never understood is how it know where one “word” stops and another starts.
so if 9 is 1001 and 57 is 111001, how does the computer know that the “1001” in 111001 isn’t whatever 11 is and then the number 9, 1001? only having two digits, 1 and 0 seems like not enough to differentiate.
If you want to have the word “apple” written in binary, do you take the binary code of each letter and smoosh them together or is there a separate specific code for “apple”?
In: Technology
At the level of machine code and binary instructions, there are no ‘spaces’. Instead, the computer just starts reading the instruction list. Each instruction is a specific, known length, and once that length is read the instruction is over and the next one starts. Theoretically, getting the CPU to start in the middle of an instruction is possible, but in practice the code will quickly crash because none of the instructions make sense. This is actually a potential source of bugs in programs. *Edit*: an additional option is a [NOP](https://en.wikipedia.org/wiki/NOP_(code)) instruction, which acts almost identically to the ‘ ‘ character in english: it tells the computer that there’s nothing here and it can be used to separate other more useful instructions.
And as for data (which seems to be more what you are asking about, since you mention turning binary into numbers), it’s very similar. A chunk of numbers will be separated out when a variable is ‘declared’. This chunk of numbers will translate into a specific piece of data. So if you ‘declare’ a byte integer next to another byte integer, you will always know the first 8 bits are to that first number and the second 8 bits to the second number.
When there’s something in the code that needs to be read without a preknown end point, there will be something like an [EOF](https://en.wikipedia.org/wiki/End-of-file) character. It’s a number or operand or similar that the computer knows as “this is the last number of the previous set”, which can be how you get words like “pie” and “bookkeeper” working with the same instructions.
Latest Answers