octal and hexadecimal numbering systems

15
Octal & Hexadecimal Numbering System by: Leo Hernandez 11/11/2014 Intro to Computer Science 2014-2015

Upload: leo-hernandez

Post on 14-Apr-2017

85 views

Category:

Software


4 download

TRANSCRIPT

Page 1: Octal and Hexadecimal Numbering Systems

Octal & HexadecimalNumbering System

by: Leo Hernandez 11/11/2014

Intro to Computer Science 2014-2015

Page 2: Octal and Hexadecimal Numbering Systems

Different Number SystemBinary - base 2 0,1Octal - base 8 0,1,2,3,4,5,6,7Decimal - base 10 (our everyday system) 0,1,2,3,4,5,6,7,8,9Hexadecimal 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F

Page 3: Octal and Hexadecimal Numbering Systems

Why use numbering systems?Binary used to represent a bit (0,1)Octal used to represent 2 bitsHexadecimal used to represent a nibble or halfa byte (4 bits)2 Hexadecimal values represent a full byte (8 bits)

Page 4: Octal and Hexadecimal Numbering Systems

Let’s consider the letter ‘J’‘J’ has an ASCII value of 74 (more about that inanother lesson)To a computer the letter J is represented as 74Let’s try to see how the value 74 is representedin different numbering systems

Page 5: Octal and Hexadecimal Numbering Systems

Value 74In binary: 0b1001010

Page 6: Octal and Hexadecimal Numbering Systems

Value 74In binary: 0b1001010In octal: 0o112

Page 7: Octal and Hexadecimal Numbering Systems

Value 74In binary: 0b1001010In octal: 0o112In hexadecimal: 0x4A

Page 8: Octal and Hexadecimal Numbering Systems

Value 74In binary: 0b1001010In octal: 0o112In hexadecimal: 0x4AIn decimal: 74

Page 9: Octal and Hexadecimal Numbering Systems

Value 74In binary: 0b1001010In octal: 0o112In hexadecimal: 0x4AIn decimal: 74As you can see, octal and hexadecimal values help torepresent binary values which are hard for humans to workwith.Final note: Octal system is not used predominantly

Page 10: Octal and Hexadecimal Numbering Systems

Few more examplesDifferent Values in Binary and HexadecimalNumber: 1,000,000Binary: 11110100001001000000Hex: F4240

Page 11: Octal and Hexadecimal Numbering Systems

Few more examplesDifferent Values in Binary and HexadecimalText: “WORD”Binary:01010111 0100111101010010 01000100Hex: 57 4F 52 44

Page 12: Octal and Hexadecimal Numbering Systems

Converting between basesLet’s practice converting between base 2(binary) and base 16 (hexadecimal) and vice-versa:

Page 13: Octal and Hexadecimal Numbering Systems

Binary to Hex1. Take binary number and split it into fours

01101110 => 0110 | 11102. Use table to convert:

0000 = 0 0100 = 4 1000 = 8 1100 = C 0001 = 1 0101 = 5 1001 = 9 1101 = D 0010 = 2 0110 = 6 1010 = A 1110 = E 0011 = 3 0111 = 7 1011 = B 1111 = F

3. Put the values together: 6E

Page 14: Octal and Hexadecimal Numbering Systems

Hex to Binary1. Take Hex number and split into individual digits:

6E = 6 E2. Use table to convert:

0000 = 0 0100 = 4 1000 = 8 1100 = C 0001 = 1 0101 = 5 1001 = 9 1101 = D 0010 = 2 0110 = 6 1010 = A 1110 = E 0011 = 3 0111 = 7 1011 = B 1111 = F

3. Put the values together: 01101110

Page 15: Octal and Hexadecimal Numbering Systems

Take 5 to 10 minutes to try a fewyourself1. 0x 12 to binary

2. 0xF F to binary3. 0b1010 1110 to hex4. 0b1011 0011 to hex