1 / 17

Agenda

Agenda. Shortcuts converting among numbering systems Binary to Hex / Hex to Binary Binary to Octal / Octal to Binary Signed and unsigned binary numbers Addition / Subtraction of Binary Numbers Two’s Complement. Numbering System Shortcuts.

megan-kerr
Download Presentation

Agenda

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. Agenda • Shortcuts converting among numbering systems • Binary to Hex / Hex to Binary • Binary to Octal / Octal to Binary • Signed and unsigned binary numbers • Addition / Subtraction of Binary Numbers • Two’s Complement

  2. Numbering System Shortcuts It is very simple to convert binary numbers to octal or hexadecimal numbers since 8 is 2^3, and 16 is 2^4 In other words: • 1 Octal digit = 3 binary digits • 1 Hex digit - 4 binary digits

  3. Binary to Octal Notice the Pattern: • Largest 3 digit binary is 111 • 1 octal digit will represent a 3 digit binary number • Highest Octal digit is 7 • Therefore: 1112 = 78

  4. Binary to Octal Relationship: Octal Binary 0 000 1 001 2 010 3 011 4 100 5 101 6 110 7 111 Does this table look familiar?

  5. Practical Example • applying octal values of rwx the chmod command (e.g., chmod 751). • chmod 777 • chmod 755 • chmod 711 • chmod 644

  6. Binary to Hexadecimal Notice the Pattern: • Largest 4 digit binary is 1111 • 1 hex digit will represent a 4 digit binary number • Highest hex digit is F • Therefore: 11112 = F16

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

  8. Convert Hex to Binary Steps: • Convert Hex number to groups of powers of 2. • Convert to Binary number (Remember to drop leading zeros for first set of binary numbers - i.e. first left set)

  9. Convert Hex to Binary 11F616 • 1 1 F 6 • 000(1) 000(1) (8)(4)(2)(1) 0(4)(2)0 • 1 0001 1111 0110 • 10001111101102 Drop Leading zeros 000

  10. Convert Binary to Hex Steps: • Separate into 4 bit groups starting from the right. • Calculate decimal equivalent (in placeholders in powers of 2) • Convert to Hexadecimal number

  11. Convert Binary to Hex 10001111101102 • 1 0001 1111 0110 • 0001 0001 1111 0110 • 1 1 (8)(4)(2)(1) 0(4)(2)0 • 1 1 15 6 • 11F616

  12. Converting Octal to Hexadecimal • The easiest method to convert between Octal and Hexadecimal is to convert to binary as an intermediate step • Regroup binary in groups of 4 for hexadecimal and 3 for octal

  13. Storing Numbers • Numeric information (stored as a non negative number) is often store in a computer in binary. Eg. • 1 byte (0 - 255 numbers) • 2 bytes (0 - 65535) • 4 bytes (0-4294967295)

  14. Data Formats Unsigned Binary • Data stored as a binary number, with no way to express a negative quantity

  15. Data Formats Signed Binary • Data stored as a binary number, but using a leading zero to represent a positive number, and the two’s complement of a binary number for a negative number

  16. Adding / Subtracting Binary Numbers • Addition: 0 + 0 = 0 0 + 1 = 1, 1 + 0 = 1 1 + 1+ = 10 • Subtraction: 0 - 0 = 0 1 - 1 = 0, 1 - 0 = 1 0 - 1 (Must borrow from next placeholder) Therefore 10 - 1 = 1

  17. Two’s Complement • Simple method of subtracting two binary numbers by adding. • Two Complement • Flip binary numbers (0 becomes 1, visa versa) • then add 1 • Result becomes negative • Therefore, short-hand method of representing negative integers

More Related