I was talking to Zvanut in #automags and he was curious about learning how to program. But he asked an interesting question... "How do I learn it right?" You can always pick up a book on some PL (Programming Language) and start using it... but the funny thing is that you really won't understand how the PL itself, and computers in general, actually works just by using it. There's lots and lots of background info.
I figure most of you could care less, but hey, this is the Friendly Corner so I can say what I want, right?
If this is boring to ya, I can easily quit. If there's continued interest... I'll periodically make additions. Oh, and I will avoid being overly technical... try to keep things simple...
<B>What is Binary? </B>
Everybody knows that computers use 1's and 0's. But what does that really mean? 1/0... on/off... sure. These 1's and 0's represent something that the computer can understand. What these 1's and 0's mean depend on the context in which they are used. A list of binary could represent some numerical value... maybe a letter... maybe a memory address where some information is stored... an instruction to add two numbers together. Could be anything.
Example: 01101001 could mean the number 105 if it was intended to represent a number. It could also be the letter 'i' if it was meant to represent a character. There are particular rules you follow to represent particular things with binary... which I won't get into.
Why do computers use binary (base 2)? Why can't they use numbers 1-10 (base 10)? This is largely to do with the way the electrical components work. The problem is that they can only <B>accurately</B> and <B>reliably</B> (calibration, interference, transistor behavior issues) tell the difference between two voltage states: low voltage, and high voltage. Low voltage is typically around 0 volts, high voltage around 5... depending. And, usually low voltage represents a 0, and high represents a 1. If some brilliant electrical engineer figured out how to tell the difference between 10 voltage states, then computers could work in the decimal number system like we do.
What does it mean that my computer is a 32 bit system? Well, it kinda depends on what you're talking about... but for the most part it means that the largest values that the CPU can deal with in one shot is 32-bits (which is a pretty big number). So like... say you were adding two numbers together... if you deal with stuff that goes over 32 bits it won't work right. You can add arbitrarily large numbers beyond 32-bits if you have the memory for it, but the CPU cannot do it on it's own... you have to tell it how to by using combinations of its 32-bit instructions. (Basically you end up breaking the big number into chunks and deal with it a piece at a time)
Why is this important? Well, once you start programming... it's good to know how the computer stores numbers/values/etc. and processes them. Like say you just started out with C++. A common question is "Why do I have to tell it what kind of stuff I'll be putting into my variables?"
ie: How come I can't just skip the the 2nd line w/o the first?:
int x, y, z;
z = x + y;
Well, when you tell the computer that x, y and z are integers (int)... it knows how much space in memory to set aside for them... and it knows that it's the kind of values that you can do arithmetic with. Going back to what I said before... remember how 01100110 could mean 105 or the letter 'i'? The computer doesn't know what it means unless you tell it what it is. This is why you have to tell the computer in your c++ programs what your variables represent.
Questions? Comments? Praise? Middle-Fingers?
This stuff is fun to me and off the top of my head so it's effortless typing it out, and I get bored a lot - especially at work... so if ya guys are interested in additions... I could...
I figure most of you could care less, but hey, this is the Friendly Corner so I can say what I want, right?
If this is boring to ya, I can easily quit. If there's continued interest... I'll periodically make additions. Oh, and I will avoid being overly technical... try to keep things simple... <B>What is Binary? </B>
Everybody knows that computers use 1's and 0's. But what does that really mean? 1/0... on/off... sure. These 1's and 0's represent something that the computer can understand. What these 1's and 0's mean depend on the context in which they are used. A list of binary could represent some numerical value... maybe a letter... maybe a memory address where some information is stored... an instruction to add two numbers together. Could be anything.
Example: 01101001 could mean the number 105 if it was intended to represent a number. It could also be the letter 'i' if it was meant to represent a character. There are particular rules you follow to represent particular things with binary... which I won't get into.
Why do computers use binary (base 2)? Why can't they use numbers 1-10 (base 10)? This is largely to do with the way the electrical components work. The problem is that they can only <B>accurately</B> and <B>reliably</B> (calibration, interference, transistor behavior issues) tell the difference between two voltage states: low voltage, and high voltage. Low voltage is typically around 0 volts, high voltage around 5... depending. And, usually low voltage represents a 0, and high represents a 1. If some brilliant electrical engineer figured out how to tell the difference between 10 voltage states, then computers could work in the decimal number system like we do.
What does it mean that my computer is a 32 bit system? Well, it kinda depends on what you're talking about... but for the most part it means that the largest values that the CPU can deal with in one shot is 32-bits (which is a pretty big number). So like... say you were adding two numbers together... if you deal with stuff that goes over 32 bits it won't work right. You can add arbitrarily large numbers beyond 32-bits if you have the memory for it, but the CPU cannot do it on it's own... you have to tell it how to by using combinations of its 32-bit instructions. (Basically you end up breaking the big number into chunks and deal with it a piece at a time)
Why is this important? Well, once you start programming... it's good to know how the computer stores numbers/values/etc. and processes them. Like say you just started out with C++. A common question is "Why do I have to tell it what kind of stuff I'll be putting into my variables?"
ie: How come I can't just skip the the 2nd line w/o the first?:
int x, y, z;
z = x + y;
Well, when you tell the computer that x, y and z are integers (int)... it knows how much space in memory to set aside for them... and it knows that it's the kind of values that you can do arithmetic with. Going back to what I said before... remember how 01100110 could mean 105 or the letter 'i'? The computer doesn't know what it means unless you tell it what it is. This is why you have to tell the computer in your c++ programs what your variables represent.
Questions? Comments? Praise? Middle-Fingers?
This stuff is fun to me and off the top of my head so it's effortless typing it out, and I get bored a lot - especially at work... so if ya guys are interested in additions... I could...


--


Comment