EMB1006 The Binary System There is no 2 Jonathan-Lee Jones
Overview Basics 8bit unsigned Binary Addition Binary Multiplication Binary Division
The Basics We use a what is called base 10 for our number system. This includes the digits 0-9 and is very easy for us as most of us have 10 fingers to help count. Computers do not have 10 fingers, they use electric current, and so, as this can only be on or off, use binary. Binary has 2 digits, 0 and 1, and is also known as base 2.
The Basics Binary numbers are refered to by the number of digits, or ‘bits’ that make them up. Computers used to operate on 8 bits, then 16, 32 and now at 64bits (Or even in some cases 128bits) The number of bits gives the range (and accuracy) of numbers that can be dealt with, the amount of addresses that can be looked up, and more. In our examples we will look at 8 bit (as bigger would give me a headache!)
8bit Unsigned For any size binary number you work the range out by raising 2 to the power of the number of bits. 2 bits gives 2^2=4 4 bits gives 2^4=16 8 bits gives 2^8= bits 2^32=4,294,967,296
8bit Unsigned
8bit Unsigned
8bit Unsigned
8bit Unsigned
8bit Unsigned ERROR!!!
8bit Signed It is common to represent negative numbers in Binary by a few different methods.
8bit Signed Signed Magnitude:The simplest way to indicate negation is signed magnitude. In signed magnitude, the left-most bit is not actually part of the number, but is just the equivalent of a +/- sign. "0" indicates that the number is positive, "1" indicates negative. In 8 bits, would be 12 (break this down into (1*2^3) + (1*2^2) ). To indicate -12, we would simply put a "1" rather than a "0" as the first bit:
8bit Signed (Signed Magnitude)
8bit Signed (Signed Magnitude)
8bit Signed (Signed Magnitude)
8bit Signed (Signed Magnitude)
8bit Signed (Signed Magnitude)
8bit Signed (Signed Magnitude) ERROR!!! -128ERROR!!!
8bit Signed One's Complement: In one's complement, positive numbers are represented as usual in regular binary. However, negative numbers are represented differently. To negate a number, replace all zeros with ones, and ones with zeros - flip the bits. Thus, 12 would be , and -12 would be As in signed magnitude, the leftmost bit indicates the sign (1 is negative, 0 is positive). To compute the value of a negative number, flip the bits and translate as before.
8bit Signed (One’s Complement)
8bit Signed (One’s Complement) ERROR!!! -128ERROR!!!
8bit Signed Two's Complement: Begin with the number in one's complement. Add 1 if the number is negative. Twelve would be represented as , and -12 as To verify this, let's subtract 1 from , to get If we flip the bits, we get , or 12 in decimal.
8bit Signed (Signed Magnitude)
8bit Signed (Signed Magnitude)
8bit Signed (Signed Magnitude)
8bit Signed (Signed Magnitude)
8bit Signed (Signed Magnitude)
8bit Signed (Signed Magnitude) ERROR!!!
Binary Addition Consider the addition of decimal numbers: = We begin by adding 3+8=11. Since 11 is greater than 10, a one is put into the 10's column (carried), and a 1 is recorded in the one's column of the sum. Next, add {(2+4) +1} (the one is from the carry)=7, which is put in the 10's column of the sum. Thus, the answer is 71.
Binary Addition Binary addition works on the same principle, but the numerals are different. Begin with one-bit binary addition: 0+0=0; 0+1=1; 1+0=1 1+1 carries us into the next column. In decimal form, 1+1=2. In binary, any digit higher than 1 puts us a column to the left (as would 10 in decimal notation). The decimal number "2" is written in binary notation as "10" (1*2^1)+(0*2^0). Record the 0 in the ones column, and carry the 1 to the twos column to get an answer of "10."
Binary Addition The process is the same for multiple-bit binary numbers: = Step one: Column 2^0: 0+1=1. Record the 1. Temporary Result: 1; Carry: 0 Step two: Column 2^1: 1+1=10. Record the 0, carry the 1. Temporary Result: 01; Carry: 1 Step three: Column 2^2: 1+0=1 Add 1 from carry: 1+1=10. Record the 0, carry the 1. Temporary Result: 001; Carry: 1 Step four: Column 2^3: 1+1=10. Add 1 from carry: 10+1=11. Record the 11. Final result: 11001
Binary Addition Always remember 0+0=0 1+0=1 1+1=
Binary Addition Always remember 0+0=0 1+0=1 1+1=
Binary Multiplication Multiplication in the binary system works the same way as in the decimal system: 1*1=1 1*0=0 0*1=0 101 * *
Binary Division Follow the same rules as in decimal division. For the sake of simplicity, throw away the remainder. For Example: / r 10 _______ 11) ______ ______ ______ 10