Binary Numbers Computer Science 2
Why Binary Numbers? Early computers were analog –Numbers were stored as an intensity –E.g. 2.7 volts was 27, 3.4 volts was 34, etc. This limited the capabilities of computers –Limited the size of the number –Limited the accuracy –Power fluctuations could cause serious errors so computers were not very robust
Digital Computers Computer engineers sought to store numbers using switches Switches are either on or off –Means power fluctuations do not introduce inaccuracy. –But how do you store more than two numbers? The answer lies in different numbering systems.
Our numbering system Called base 10 or decimal –10 possibilities for each digit (1-9 or zero). –Rightmost digit multiplied by 1 –2nd to rightmost multiplied by 10 1 (10) –3rd to rightmost multiplied by 10 2 (100) –4th to rightmost multiplied by 10 3 (1,000) –etc.
A base 10 number 8,507 7x10 0 = 7 0x10 1 = 0 5x10 2 = 500 8x10 3 =
Base 10 isn’t the only numbering system Base 16 (or hexadecimal) –16 possibilities for each digit (1-15 and 0) –Rightmost digit still multipled by 1 –Next to rightmost digit multiplied by 16 1 =16 –Next digit multiplied by 16 2 =256 Base 2 (or binary) –2 possibilities for each digit (1 and 0) –Right must digit mulitplied by 1 –Next to right most multiplied by 2 1 =2 –Next multiplied by 2 2 =4 –Ideal for storing numbers using on/off switches!
A binary number x2 0 = 1 0x2 1 = 0 1x2 2 = 4 1x2 3 = Note that binary numbers are represented using the subscript 2 ( 2 )
Summary Multiple number systems exist –We use decimal or base 10 –Also base 16 (hexadecimal) and base 2 (binary) Binary numbers are used in computers because they are easy to store using on/off switches. –Each digit can be 1 or 0 –First digit multiplied by 2 0, next by 2 1, third by 2 2, etc. –Denoted by following binary numbers with the subscript 2 (e.g )