Krista's Coding Corner

03.09.2013

AND, NOT, XOR??

Computers are dealing with 0's and 1's, some voltage and somewhat no-voltage. We have dealed with this in What is programming / coding?

But how we go from those differenting states to calculating and executing programs? Our computers are based on electricity, so we go to electronics now but don't worry, nothing complex here.

First step, understanding small parts: The most simple logic operators are AND, NOT, OR, XOR.

AND: you have two inputs and one output. If both inputs have voltage the AND-parts output will put voltage forward.

NOT: you have one input, one output. If input has voltage, output won't, and vice versa.

OR: you have two inputs, one output. If at least other input has voltage, the output will also put voltage forward.

XOR: this is like OR but it will put voltage forward only if other input has voltage. If both have, it will remain as mute as if both inputs wouldn't have voltage.

Still with me? Hope so :)

At this point I just have to introduce you to Mr. Logicbox: he is a bit simple minded but very straight forward and doesn't make fuss about things. I got him once as a birthday gift <3

But he doesn't have those simple logic operators in him. There is something else: NAND and NOR. The N in front of the letters means 'not'.

NAND: could be translated into AND-NOT, so first we have normal AND and then NOT. Like this:

NOR: could be translated into OR-NOT in this manner:

Now you probably wonder why on earth someone has gone though so much trouble and made those complicated logic operators instead of just AND, OR and NOT as separated cases. Easy aswear: NAND and NOR are easier to build and take less parts than just AND and OR. This may not make too much sense if you are not educated in the field of electronics. But it is due to transistors which are, in practise, NOT-operators we can use to build more complicated operators like AND and NAND.

(Sorry, I'll have to postpone 'how transistor works as NOT' and 'how multiple NOTs can make something great' texts to later posts as those topics are a bit complicated).

blog comments powered by Disqus