Presentation is loading. Please wait.

Presentation is loading. Please wait.

© 2003-2008 BYU 02 NUMBERS Page 1 ECEn 224 Binary Number Systems and Codes.

Similar presentations


Presentation on theme: "© 2003-2008 BYU 02 NUMBERS Page 1 ECEn 224 Binary Number Systems and Codes."— Presentation transcript:

1 © 2003-2008 BYU 02 NUMBERS Page 1 ECEn 224 Binary Number Systems and Codes

2 © 2003-2008 BYU 02 NUMBERS Page 2 ECEn 224 Positional Numbers What does 5132.13 really mean? Depends on the number base! Assuming base 10: 5132.13 10 = 5x10 3 + 1x10 2 + 3x10 1 + 2x10 0 + 1x10 -1 + 3x10 -2 Assuming base 6: 5132.13 6 = 5x6 3 + 1x6 2 + 3x6 1 + 2x6 0 + 1x6 -1 + 3x6 -2 We often use a subscript to indicate the base.

3 © 2003-2008 BYU 02 NUMBERS Page 3 ECEn 224 Positional Number Examples 527.46 10 = (5 x 10 2 ) + (2 x 10 1 ) + (7 x 10 0 ) + (4 x 10 -1 ) + (6 x 10 -2 ) 527.46 8 = (5 x 8 2 ) + (2 x 8 1 ) + (7 x 8 0 ) + (4 x 8 -1 ) + (6 x 8 -2 ) 527.46 5 = illegal why? 1011.11 2 = (1 x 2 3 ) + (0 x 2 2 ) + (1 x 2 1 ) + (1 x 2 0 ) + (1 x 2 -1 ) + (1 x 2 -2 ) This works for binary as well…

4 © 2003-2008 BYU 02 NUMBERS Page 4 ECEn 224 Conversion from Binary Convert 101011.11 2 to base 10: 101011.11 2 = 1x2 5 + 0x2 4 + 1x2 3 + 0x2 2 + 1x2 1 + 1x2 0 + 1x2 -1 + 1x2 -2 = 32 + 0 + 8 + 0 + 2 + 1 + ½ + ¼ = 43.75 10

5 © 2003-2008 BYU 02 NUMBERS Page 5 ECEn 224 Convert 114 10 to binary: 114 50 18 2 - 64 1x2 6 - 32 1x2 5 - 16 1x2 4 2 - 0 0x2 3 2 - 0 0x2 2 0 - 2 1x2 1 - 0 0x2 0 0 114 10 = 1110010 2 Read this way This method also works for fractional numbers.

6 © 2003-2008 BYU 02 NUMBERS Page 6 ECEn 224 114 An Alternate Method 2 2 2 2 2 2 2 57 R 0 28 R 1 14 R 0 7 R 0 3 R 1 1 R 1 0 R 1 114 10 = 1110010 2 Read this way

7 © 2003-2008 BYU 02 NUMBERS Page 7 ECEn 224 Converting fractions from base 10 to binary: Convert 0.7 10 to binary 0.7 x 2 (1).4 x 2 (0).8 x 2 (1).6 x 2 (1).2 x 2 (0).4 x 2 (0).8 process starts repeating here 0.7 10 = 0.1 0110 0110 … 2 Read this way

8 © 2003-2008 BYU 02 NUMBERS Page 8 ECEn 224 Convert 114.7 10 to binary: We could use the first technique. 114.7 - 641x2 6 50.7 - 321x2 5 18.7 - 161x2 4 2.7 - 00x2 3 2.7 - 00x2 2 2.7 - 21x2 1 0.7 - 00x2 0 0.7 - 0.51x2 -1 0.2 - 0.00x2 -2 0.2 - 0.1251x2 -3 0.075 … Read this way 112 10 = 1110010.10... 2

9 © 2003-2008 BYU 02 NUMBERS Page 9 ECEn 224 Convert 114.7 10 to binary: Or we could combine the second and third techniques. 112 10 = 1110010.10110... 2 114 2 2 2 2 2 2 2 57 R 0 28 R 1 14 R 0 7 R 0 3 R 1 1 R 1 0 R 1 0.7 x 2 (1).4 x 2 (0).8 x 2 (1).6 x 2 (1).2 x 2 (0).4 x 2 (0).8 Read this way

10 © 2003-2008 BYU 02 NUMBERS Page 10 ECEn 224 Hexadecimal Commonly used for binary data –1 hex digit  4 binary digits (bits) Need more digits than just 0-9 –Use 0-9, A-F A-F are for 10-15 FA2 16 = 15x16 2 + 10x16 1 + 2x16 0 FA2 16 = 1111 1010 0010 Each group of 4 bits  1 hex digit

11 © 2003-2008 BYU 02 NUMBERS Page 11 ECEn 224 Other Notations For Binary and Hex Binary –10110 2 –10110b –0b10110 Hexadecimal –573 16 –0x573 –573h –16#573

12 © 2003-2008 BYU 02 NUMBERS Page 12 ECEn 224 Other Codes BCD ASCII Gray

13 © 2003-2008 BYU 02 NUMBERS Page 13 ECEn 224 Binary Coded Decimal (BCD) Convert 2496 10 to BCD Code 2 4 9 6 0 0 1 0 0 1 0 0 1 0 0 1 0 1 1 0 Note this is very different from converting to binary which yields: 1 0 0 1 1 1 0 0 0 0 0 0 2

14 © 2003-2008 BYU 02 NUMBERS Page 14 ECEn 224 Binary Coded Decimal (BCD) Why use BCD? In some applications it may be easier to work with Financial institutions must be able to represent base 10 fractions (e.g., 1/10) –0.1 10 = 0.00110011001100… 2 –Using BCD ensures that numeric results are identical to base 10 results

15 © 2003-2008 BYU 02 NUMBERS Page 15 ECEn 224 Binary Codes ASCII Code ASCII  American Standard Code for Information Interchange ASCII is a 7-bit code used to represent letters, symbols, and terminal codes There are also Extended ASCII codes, represented by 8-bit numbers Terminal codes include such things as: Tab (TAB) Line feed (LF) Carriage return (CR) Backspace (BS) Escape (ESC) And many more!

16 © 2003-2008 BYU 02 NUMBERS Page 16 ECEn 224 Binary Codes ASCII Code

17 © 2003-2008 BYU 02 NUMBERS Page 17 ECEn 224 Binary Codes Extended ASCII Code

18 © 2003-2008 BYU 02 NUMBERS Page 18 ECEn 224 Binary Codes ASCII Code (partial) Convert “help” to ASCII h e l p 1101000 1100101 1101100 1111000 0x68 0x65 0x6C 0x70

19 © 2003-2008 BYU 02 NUMBERS Page 19 ECEn 224 Binary Codes Gray Code Only one bit changes with each number increment Not a weighted code Useful for interfacing to some physical systems

20 © 2003-2008 BYU 02 NUMBERS Page 20 ECEn 224 Gray Codes are Not Unique

21 © 2003-2008 BYU 02 NUMBERS Page 21 ECEn 224 Codes - Summary Bits are bits… –Modern digital devices represent everything as collections of bits –A computer is one such digital device You can encode anything with sufficient 1’s and 0’s –Text (ASCII) –Computer programs (C code, assembly code, machine code) –Sound (.wav,.mp3, …) –Pictures (.jpg,.gif,.tiff)


Download ppt "© 2003-2008 BYU 02 NUMBERS Page 1 ECEn 224 Binary Number Systems and Codes."

Similar presentations


Ads by Google