Presentation is loading. Please wait.

Presentation is loading. Please wait.

Binary Numbers Douglas Wilhelm Harder Department of Electrical and Computer Engineering University of Waterloo Copyright © 2007 by Douglas Wilhelm Harder.

Similar presentations


Presentation on theme: "Binary Numbers Douglas Wilhelm Harder Department of Electrical and Computer Engineering University of Waterloo Copyright © 2007 by Douglas Wilhelm Harder."— Presentation transcript:

1 Binary Numbers Douglas Wilhelm Harder Department of Electrical and Computer Engineering University of Waterloo Copyright © 2007 by Douglas Wilhelm Harder. All rights reserved. ECE 204 Numerical Methods for Computer Engineers

2 Binary Numbers This topic introduces binary numbers –standard notation –scientific notation –addition –multiplication

3 Binary Numbers Decimal numbers are convenient for humans because we have 10 fingers (also called “digits”) Otherwise, they are exceptionally useless as 10 has only two divisors: 2 and 5 Even our day is more conveniently broken up into base 12 which has four divisors: 2, 3, 4, and 6

4 Binary Numbers Representing ten digits is exceptionally inconvenient for computers It is easiest to represent just two digits with closed and open circuits ( 5 V and 0 V ) We use 0 and 1 to represent these two binary digits, or bits

5 Binary Numbers We represent a binary integer as a sequence of bits b n b n – 1 · · · b 1 b 0 which equals

6 Binary Numbers For example, 101010 represents 1·2 5 + 0·2 4 + 1·2 3 + 0·2 2 + 1·2 1 + 0·2 0 = 32 + 16 + 2 = 42 As another example, 1110001 represents 1·2 6 + 1·2 5 + 1·2 4 + 0·2 3 + 0·2 2 + 0·2 1 + 1·2 0 = 64 + 32 + 16 + 1 = 113

7 Binary Numbers In counting, we always increment the next digit whenever we increment a “1”: 1 10 11 100 101 110 111 1000 1001 1010 1011 1100

8 Binary Numbers We use these numbers to represent the integers in the natural order: 1 1 10 2 11 3 100 4 101 5 110 6 111 7 1000 8 1001 9 1010 10 1011 11 110012

9 Binary Numbers Binary numbers are very convenient for computers, but very inconvenient for humans –for example, how much smaller is 110010 than 111110100? –these are 50 and 500, respectively

10 Binary Numbers Just like decimal real numbers, we can represent a real number as a sequence of bits: b n b n – 1 · · · b 1 b 0. b –1 b –2 b –3 · · · where b n  0 (i.e., b n = 1 ), and n is any integer This represents the number

11 Binary Numbers We cannot call the point in b n b n – 1 · · · b 1 b 0. b –1 b –2 b –3 · · · a “decimal point”, as this is not a decimal number The generic name for the point is the radix point

12 Binary Numbers As with decimal digits, we are only concerned with a finite number of bits: b n b n – 1 · · · b 0. b –1 · · · b m where b n = 1, n is any integer and m  n This represents the number

13 Binary Numbers For example,  represents 1·2 2 + 0·2 1 + 1·2 0 + 1·2 –1 + 0·2 –2 + 1·2 –3 = 4 + 1 + 0.5 + 0.125 = 5.625 As another example,  represents 1·2 0 + 0·2 –1 + 1·2 –2 + 1·2 –3 + 0·2 –4 + 1·2 –5 = 1 + 0.25 + 0.125 + 0.03125 = 1.40625

14 Binary Numbers Notice that 101.101 is 1.01101 differ only by shifting the radix point by two locations This is equivalent to multiply by 2 –2 or dividing by 4 We also see that 

15 Binary Numbers As with decimal numbers, we can represent binary numbers using scientific notation: Any real number can be written as 1.b -1 b -2 b -3 · · · b –m  2 n which often written as 1.b -1 b -2 b -3 ···b –m en

16 Binary Numbers To differentiate between binary numbers and decimal numbers it is common to add a subscript 2 or subscript 10: 101010 2 = 42 10 0.10101 2 = 0.65625 10 1111101000 2 = 1000 10 10000000000 2 = 1024 10 Note that 42/64 = 0.65625

17 Binary Numbers To add two binary numbers: –line up the radix points, add the columns, carrying 1 to next column if the sum is greater than 1 : –for example, add 1011.1 = 1.0111  2 3 and 1.1101 = 1.0111  2 0 yielding 1.1010101  2 3 = 1101.0101

18 Binary Numbers Multiplication of numbers in scientific notation is similar, multiply the mantissa and add the exponents –for example, multiply 101100 = 1.011  2 5 and 0.1101 = 1.101  2 –1 yielding 10.001111  2 4 =1.0001111  2 5

19 Binary Numbers We can verify this by converting to decimal numbers: 101100 2 = 44 10 0.1101 2 = 0.8125 10 where 44  0.8125 = 35.75 and 1.0001111  2 5 = 100011.11 = 32 + 2 + 1 + 0.5 + 0.25 = 35.75

20 Binary Numbers Thus, we have seen that the mechanics of binary numbers are identical to the mechanics of decimal numbers

21 Usage Notes These slides are made publicly available on the web for anyone to use If you choose to use them, or a part thereof, for a course at another institution, I ask only three things: –that you inform me that you are using the slides, –that you acknowledge my work, and –that you alert me of any mistakes which I made or changes which you make, and allow me the option of incorporating such changes (with an acknowledgment) in my set of slides Sincerely, Douglas Wilhelm Harder, MMath dwharder@alumni.uwaterloo.ca


Download ppt "Binary Numbers Douglas Wilhelm Harder Department of Electrical and Computer Engineering University of Waterloo Copyright © 2007 by Douglas Wilhelm Harder."

Similar presentations


Ads by Google