1 / 23

Binary (Base 2, b) Octal (Oct, Base 8) Hexadecimal (Hex, Base 16, h, 0x) Decimal (Base 10, d)

Binary (Base 2, b) Octal (Oct, Base 8) Hexadecimal (Hex, Base 16, h, 0x) Decimal (Base 10, d). OR Counting for Aliens. Why Binary and Hex?.

verena
Download Presentation

Binary (Base 2, b) Octal (Oct, Base 8) Hexadecimal (Hex, Base 16, h, 0x) Decimal (Base 10, d)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Binary (Base 2, b)Octal (Oct, Base 8)Hexadecimal (Hex, Base 16, h, 0x)Decimal (Base 10, d) ORCounting for Aliens

  2. Why Binary and Hex? Computers are essentially dumb machines which can only do operations in base 2. They have many many “switches” in their processors each of which can either be on (1) or off (0). Hence all data that is to be manipulated on a computer must be converted to binary behind the scenes. Hex is just a convenient way to avoid working in straight binary.

  3. Representing numbers in differentbases (back to elementary school math) We all agree we have 14 dots!

  4. Representing numbers in differentbases (back to elementary school math) 1 group of ten and 4 groups of 1 = 14 base 10

  5. Representing numbers in differentbases (back to elementary school math) 1 group of 8 and 6 groups of one = 16 base 8

  6. Representing numbers in differentbases (back to elementary school math) 1 group of 8 and 1 group of 1 four and 1 group of 2 and 0 groups of ones = 1110 base 2

  7. Binary to Decimal 10010 base 2 = 16 + 2 = 18 base 10 Let’s try a game………..

  8. Decimal to Binary (method 1) from askville.amazon.com I) Find the greatest power of two that's smaller than or equal to your number. Put a 1 in that power's place. II) Subtract that power of two from your number. If the result is 0, go to step IV. III) Let your new number be the difference computed in step II. Go to Step I. IV) Fill in 0's in all positions that you haven't already filled in with 1s. So, let's do this for a number like 2000 decimal: The greatest power of 2 smaller than 2000 is 1024. So we'll put a 1 in that place: 1 _ _ _ _ _ _ _ _ _ _ _ 2000 - 1024 = 976 Greatest power of two less than 976 is 512. Put a 1 in that place: 1 1 _ _ _ _ _ _ _ _ _ _ 976 - 512 = 464 Greatest power of two less than 464 is 256. Put a 1 in that place: 1 1 1 _ _ _ _ _ _ _ _ _ 464 - 256 = 208. Greatest power of two less than 208 is 128. Put a 1 in that place: 1 1 1 1 _ _ _ _ _ _ _ _ 208 - 128 = 80 Greatest power of two less than 80 is 64. Put a 1 in that place: 1 1 1 1 1 _ _ _ _ _ _ _ 80 - 64 = 16 Greatest power of two less than (or equal to) 16 is 16. Put a 1 in that place: 1 1 1 1 1 _ 1 _ _ _ _ _ 16 - 16 = 0 Fill in 0s in all remaining spaces: 1 1 1 1 1 0 1 0 0 0 0 0 So, 2000d = 111110100000b

  9. Decimal to Binary (method 2) Take your decimal number and divide it by 2 continuously. For example, 100 decimal = ______ in binary 100/2= 50 Remainder 0 50/2= 25, remainder 0 25/2-12 remainder 1 12/2=6, remainder 0 6/2=3, remainder 0 3/2=1 remainder 1 1/2=0 remainder 1 The remainder numbers are the binary and you read upwards So: 1100100 binary for a decimal of 100.

  10. What the Heck is Hex • Base 16 is like Base 10 EXCEPT we need more symbols • In base 10 we represent all values using 10 symbols {0 1 2 3 4 5 6 7 8 9} • In base 16 we need 6 more symbols for a total of 16 so we use letters • The symbols used in base to represent all values are {0,1,2,3,4,5,6,7,8,9,A,B,C,D,F}

  11. Binary to Hex and Hex to Binary • Each Hex digit can be easily converted to 4 binary digits. • Each group of 4 binary digits can be easily converted to hex 0h = 0000b 9h = 1001b 1h = 0001b Ah = 1010b 2h = 0010b Bh = 1011b 3h = 0011b Ch = 1100b 4h = 0100b Dh = 1101b 5h = 0101b Eh = 1110b 6h = 0110b Fh = 1111b 7h = 0111b 8h = 1000b i.e. 1 3 B 4 h = 0001 0011 1011 0100 b

  12. HEXadecimal to Decimal First off know the digits for Hex 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F So 7 base 10 = 7 base 16 But 13 base 10 = D base 16 And F base 16 = 15 base 10 This makes for some weirdness 7 + 7 = E

  13. Representing numbers in differentbases (back to elementary school math) We all agree we have 24 dots!

  14. Representing numbers in differentbases (back to elementary school math) 1 group of 16 and 8 ones = 18 base 16

  15. Representing numbers in differentbases (back to elementary school math) We all agree we have 30 dots!

  16. Representing numbers in differentbases (back to elementary school math) 1 groups of 16 and 14 ones BUT 14 needs to be represent with a single symbol not two symbols like 1 and 4. So in base 16 we use letters. We Use A for 10, B for 11, C for 12, D for 13, E for 14, and F for 15. So 30 dots is 1E in base 16.

  17. HEXadecimal to Decimal Some serious multiplication can be involved Determine your powers of 16: 1 16 256 4096 65536……… So 1AF0 base 16 = (1)4096 + (10)256 + (15)16 + (0)1 = 6896 base 10

  18. HEXadecimal to Decimal Method two (use binary to help) Every Hex digit represent 4 binary digits 0h = 0000b 9h = 1001b 1h = 0001b Ah = 1010b 2h = 0010b Bh = 1011b 3h = 0011b Ch = 1100b 4h = 0100b Dh = 1101b 5h = 0101b Eh = 1110b 6h = 0110b Fh = 1111b 7h = 0111b 8h = 1000b

  19. HEXadecimal to Decimal Method two continued (use binary to help) Convert the hex digits to groups of 4 binary digits Then convert the binary to decimal 1AF0 hex = 0001 1010 1111 0000 base 2 Working backwards 0+0+0+0+16+32+64+128+0+512+0+2048+4096+0+0+0 = 6896

  20. Decimal to HEXadecimal Method 1) Divide by 16 and write down remainders 700 base 10 / 16 = 43 Remainder 12 43/16 = 2 Remainder 11 2/16 = 0 Remainder 2 so 700 decimal = 2BC hex OR Method 2) Covert to binary and then group in 4 bits 0010 1011 1100 and convert each to a hex digit 2 B C

  21. HOMEWORK - Practice examples (convert to base 10 for addition) • 777 base 10 = ______ base 2 • 11001110 b = _______ d • 2A9 hex = ______ base 2 = ________ base 10 • 10 h + 10 d = _____ h = ______ b • 1010 b + FF h = _____ d • 16 h + 32 h = ____ d • 3D7C h = _________ base 2

  22. HOMEWORK Part 1 • Write down a method for converting between Octal (base 8) and Decimal and vice versa. • Write down a method for converting between Octal (base 8) and Binary and vice versa. • Write down a method for converting between Octal (base 8) and Hex and vice versa.

  23. Delving Deeper… • Checking your answers http://www.easycalculation.com/decimal-converter.php • Decimal(fractional) numbers in binary http://cs.furman.edu/digitaldomain/more/ch6/dec_frac_to_bin.htm http://mathforum.org/library/drmath/view/56091.html • Signed binary numbers, addition & subtraction http://en.wikipedia.org/wiki/Signed_number_representations • Multiplying and dividing in base 2 http://www.helpwithpcs.com/courses/multiplying-dividing-binary-numbers.htm

More Related