eli5 How do people code with binary?

1.29K viewsOtherTechnology

Like I get that it can be a 1 or a 0, and that stores information, but how do you get information out of that? And how do people code with it? Seems like all it could store is numbers

Edit: Thank you all, this is very helpful

In: Technology

26 Answers

Anonymous 0 Comments

Every single application you’ve ever run can be broken down to 5 things:

1. Reading and writing data
2. Operations on this data such as addition and subtraction and a couple other logical operators
3. Branches. If one value is “true” then do this instruction. If it isn’t true, do some other instruction.
4. Jump. Jump to a specific location in the instructions and start executing from there.
5. Hardware IO. This is like making a pixel a certain color or writing to a file or reading information from the network / web.

How do we do each one.

1. All data can be stored as some number. We can assign every letter / character to some value and represent this value in binary. All numbers can obviously also be represented in binary. Etc. Reading and writing is also quite simple. Let’s say that the number for a read instruction is 1 and writing is 2. You could tell the computer “2 <location, which is a number> <data, which is also a number>” and there ya go you just wrote arbitrary data to an arbitrary location.
2. Operations can also just be a number. Let’s say addition is 3. So now we can tell the computer “3 2 5” and it knows to add up 2+5
2. Jump. I’m going to do Jump first because it helps explain branching too. Let’s say the operation number for Jump is 4. Now we just have to tell it a location in the code to jump to. Let’s say we just represent this as the line number in the code. So “4 3” will move where we are executing to the 3rd line of code.
4. Branching. Guess what, we can also represent this instruction as a number. Let’s say it’s 5. Now we also have to give it some value that is true or false, and then tell it what to execute if it’s true and if it’s false. Let’s use the jump statement to tell the code where to go if the statement is true/false. So “5 <true/false> <jump statement if true> <jump statement if false>”
5. Hardware IO is a little out of my realm because I’m not an electrical / computer engineer but essentially, if you give a pixel on a screen a high voltage level, it’s going to light up. If it’s a low voltage, then it doesn’t light up. So this translates quite easily to binary

You are viewing 1 out of 26 answers, click here to view all answers.