How do you define “if” for computers?

425 views

I’m not a programmer, how do you get from binary 1s and 0s to “if x occurs complete y” How do you tell the computer to wait for a future input?

In: 2

11 Answers

Anonymous 0 Comments

At the most basic level modern computers are a bunch of transistors forming logic gates forming more complicated structures like adders.

With these structures CPUs have a small numbers of very, very basic command built into them. Stuff like take a value from the memory in place x and put it into a register or adding a number to a value in a register or incrementing a value or things of that nature.

One of the most basic command is one that tells the computer where to find the next instruction. You tell the computer to jump to an address and use what they find there as an instruction about what to do next.

In addition to that you can have conditional branching where you tell a computer to compare two values and continue with different instructions based on that comparisons.

Higher level programing languages package these very basic instruction into more complex constructs that let you easily build loops and If Else statements and similar stuff.