Computers are not magic. The software you use-- voice recognition, cell phones, social networks-- is the result of years of development and layers and layers technology. In this overview of how computers work, we focus on binary arithmetic. Software is build on levels of abstraction, each one further from the actual hardware... 1. Electric currents-- these are what really exist inside the computer. 2. 0s and 1s- ON current is 1 and an OFF current is 0 3. Machine Lanaguage -- Numbers for commands and data 4. Assembly Language -- some command and variable names but still processing memory cells and accessing addresses/registers and other hardware components directly. example: Mov 7,3456 5. High-Level Language (Java, C++, Python) Symbolic and logical, with few if any direct references to addresses, registers, or other hardware components 6. Natural Language, e.g., English Converting Binary to Decimal and ASCIIHere's a couple of video clips explaining the process:Bits and Bytes
We have only 0s and 1s, but we want to represent numbers and symbolsA bit is a single 0/1 A byte is 8 bits, e.g., 01010101 Base-10 is your friend729 is of course seven hundred and twenty nine. Our brain knows that instantly. But what is really happening?The right-most digit is multiplied by 1, the second-right-most digit is multiplied by 10, and the third right-most digit is multiplied by 100. So we get: 9*1 +2*10+7*100. In general, we multiply the ith digit (starting from the right) by 10i, e.g., 9*100+2*101+7*102.Base-2, Binary, works exactly the same, only our brains are not used to it. To represent a positive integer, we must convert binary into decimal. We do this by multiplying the ith bit by 2i. So the right-most bit is multiplied by 20, or 1, the second-right-most by 21 or 2, and the third right-most bit by 22 or 4, and so on. So 1010 binary is: 1*23+ 0*22+1*21+0*20 = 8+0+2+0 = 10 decimal Another way to put it: starting from the right most bit and going left, we assign 1,2,4,8,16,32, etc. to each bit that is 1. We can also take a binary number and convert it to binary. One way to do this is to write out the base-10 values of each bit until you find one that is larger than the number you are trying to convert. So for The base-10 number 155, we'd write out the values corresponding to the : value: 256 128 64 32 16 8 4 2 1 To get 155, we can't have the 256 bit set, but we can have a 128, so we put a '1' there. value: 256 128 64 32 16 8 4 2 1 0 1 We still need 155-128=27. 64 and 32 are too big, so we place 0s there and put a 1 on 16: value: 256 128 64 32 16 8 4 2 1 0 1 0 0 1 We still need 155-128-16=11. So we give a '1' to the 8-value digit. We still need 3 more, so we put a 0 in the 4-value, and 1s in the 2-value and 1-value. This gives us the binary number: value: 256 128 64 32 16 8 4 2 1 0 1 0 0 1 1 0 1 1 So 155 decimal is equal to 010011011 binary. Characters and StringsWe say that 8 bits is a byte. |