Presentation is loading. Please wait.

Presentation is loading. Please wait.

EMB1006 The Binary System There is no 2 Jonathan-Lee Jones.

Similar presentations


Presentation on theme: "EMB1006 The Binary System There is no 2 Jonathan-Lee Jones."— Presentation transcript:

1 EMB1006 The Binary System There is no 2 Jonathan-Lee Jones

2 Overview Basics 8bit unsigned Binary Addition Binary Multiplication Binary Division

3 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.

4 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!)

5 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=256 32 bits 2^32=4,294,967,296

6 8bit Unsigned 1286432168421 0 1 17 255 256

7 8bit Unsigned 1286432168421 000000000 1 17 255 256

8 8bit Unsigned 1286432168421 000000000 100000001 17 255 256

9 8bit Unsigned 1286432168421 000000000 100000001 1700010001 255 256

10 8bit Unsigned 1286432168421 000000000 100000001 1700010001 25511111111 256ERROR!!!

11 8bit Signed It is common to represent negative numbers in Binary by a few different methods.

12 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, 00001100 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: 10001100.

13 8bit Signed (Signed Magnitude) 1286432168421 1 64 -64 127 -127 128 -128

14 8bit Signed (Signed Magnitude) 1286432168421 100000001 64 -64 127 -127 128 -128

15 8bit Signed (Signed Magnitude) 1286432168421 100000001 10000001 64 -64 127 -127 128 -128

16 8bit Signed (Signed Magnitude) 1286432168421 100000001 10000001 6401000000 -6411000000 127 -127 128 -128

17 8bit Signed (Signed Magnitude) 1286432168421 100000001 10000001 6401000000 -6411000000 12701111111 -12711111111 128 -128

18 8bit Signed (Signed Magnitude) 1286432168421 100000001 10000001 6401000000 -6411000000 12701111111 -12711111111 128ERROR!!! -128ERROR!!!

19 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 00001100, and -12 would be 11110011. 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.

20 8bit Signed (One’s Complement) 1286432168421 100000001 11111110 6401000000 -6410111111 127 -127 128 -128

21 8bit Signed (One’s Complement) 1286432168421 100000001 11111110 6401000000 -6410111111 12701111111 -12710000000 128ERROR!!! -128ERROR!!!

22 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 00001100, and -12 as 11110100. To verify this, let's subtract 1 from 11110100, to get 11110011. If we flip the bits, we get 00001100, or 12 in decimal.

23 8bit Signed (Signed Magnitude) 1286432168421 1 64 -64 127 -127 128 -128

24 8bit Signed (Signed Magnitude) 1286432168421 100000001 64 -64 127 -127 128 -128

25 8bit Signed (Signed Magnitude) 1286432168421 100000001 11111111 6401000000 -64 127 -127 128 -128

26 8bit Signed (Signed Magnitude) 1286432168421 100000001 11111111 6401000000 -6411000000 12701111111 -127 128 -128

27 8bit Signed (Signed Magnitude) 1286432168421 100000001 11111111 6401000000 -6411000000 12701111111 -12710000001 128 -128

28 8bit Signed (Signed Magnitude) 1286432168421 100000001 11111111 6401000000 -6411000000 12701111111 -12710000001 128ERROR!!! -12810000000

29 Binary Addition Consider the addition of decimal numbers: 23 +48 = 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.

30 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."

31 Binary Addition The process is the same for multiple-bit binary numbers: 1010 +1111 = 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

32 Binary Addition Always remember 0+0=0 1+0=1 1+1=10 111101111 +110+111

33 Binary Addition Always remember 0+0=0 1+0=1 1+1=10 111101111 +110+111 110111001110

34 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 *11 1111 101 *11 101 1010

35 Binary Division Follow the same rules as in decimal division. For the sake of simplicity, throw away the remainder. For Example: 111011/11 10011 r 10 _______ 11)111011 -11 ______ 101 -11 ______ 101 11 ______ 10


Download ppt "EMB1006 The Binary System There is no 2 Jonathan-Lee Jones."

Similar presentations


Ads by Google