• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Number Systems CPSC125
 

Number Systems CPSC125

on

  • 2,299 views

Number systems, bases and base conversions (decimal, binary, octal, hexadecimal). This lecture covers material not in the text.

Number systems, bases and base conversions (decimal, binary, octal, hexadecimal). This lecture covers material not in the text.

Statistics

Views

Total Views
2,299
Views on SlideShare
2,292
Embed Views
7

Actions

Likes
4
Downloads
132
Comments
0

1 Embed 7

http://www.slideshare.net 7

Accessibility

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Number Systems CPSC125 Number Systems CPSC125 Presentation Transcript

    • Number Systems Spring 2010 Dr. David Hyland-Wood University of Mary Washington Monday, January 11, 2010
    • Information Encoding We use encoding schemes to represent and store information. • Roman Numerals: I, IV, XL, MMIV • Acronyms: UMW, CPSC-125, SSGN-726 • Postal codes: 22401, M5W 1E6 • Musical Note Notation: Encoding schemes are only useful if the stored information can be retrieved. Monday, January 11, 2010
    • Monday, January 11, 2010 Linear A has not been deciphered. This tablet stores information, but it can no longer be retrieved. Think about floppy disks, tape drives, bad handwriting and other forms of “lost” data.
    • Decimal Notation • base 10 or radix 10 ... uses 10 symbols 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 • Position represents powers of 10 • 5473 or 5473 10 (5 * 103) + (4 * 102) + (7 * 101) + (3 * 100) • 73.19 10 or 73.19 (7 * 101) + (3 * 100) + (1 * 10-1) + (9 * 10-2) Monday, January 11, 2010
    • Monday, January 11, 2010 There is an obvious reason to use base 10.
    • Monday, January 11, 2010 The ancient Sumerians used base 12, which is why we inherited a 12-hour clock.
    • Binary Notation • base 2 ... uses only 2 symbols 0, 1 • Position represents powers of 2 • 11010 2 (1 * 24) + (1 * 23) + (0 * 22) + (1 * 21) + (0 * 20) • 10.11 2 (1 * 21) + (0 * 20) + (1 * 2-1) + (1 * 2-2) Monday, January 11, 2010
    • Monday, January 11, 2010 Computers are binary all the way down. Electrical signals are “on” or “off” based on voltage. Magnetic storage systems such as hard disc drives are based on magnetism. Optical storage systems are based on depth.
    • “On” or “Off” Monday, January 11, 2010 Computers are binary all the way down. Electrical signals are “on” or “off” based on voltage. Magnetic storage systems such as hard disc drives are based on magnetism. Optical storage systems are based on depth.
    • “On” or “Off” voltage threshold time Monday, January 11, 2010 Computers are binary all the way down. Electrical signals are “on” or “off” based on voltage. Magnetic storage systems such as hard disc drives are based on magnetism. Optical storage systems are based on depth.
    • “On” or “Off” “On” voltage threshold “Off” time Monday, January 11, 2010 Computers are binary all the way down. Electrical signals are “on” or “off” based on voltage. Magnetic storage systems such as hard disc drives are based on magnetism. Optical storage systems are based on depth.
    • “On” or “Off” “On” 1 voltage threshold “Off” 0 time Monday, January 11, 2010 Computers are binary all the way down. Electrical signals are “on” or “off” based on voltage. Magnetic storage systems such as hard disc drives are based on magnetism. Optical storage systems are based on depth.
    • “On” or “Off” “On” 1 True voltage threshold “Off” 0 False time Monday, January 11, 2010 Computers are binary all the way down. Electrical signals are “on” or “off” based on voltage. Magnetic storage systems such as hard disc drives are based on magnetism. Optical storage systems are based on depth.
    • Octal Notation • base 8 ... uses 8 symbols 0, 1, 2, 3, 4, 5, 6, 7 • Position represents power of 8 • 1523 8 (1 * 8 3) + (5 * 8 2) + (2 * 8 1) + (3 * 8 0) • 56.72 8 (5 * 81) + (6 * 80) + (7 * 8-1) + (2 * 8-2) Monday, January 11, 2010
    • Hexadecimal Notation • base 16 or ‘hex’ ... uses 16 symbols 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F • Position represents powers of 16 • B65F or 0xB65F 16 (11 * 163) + (6 * 162) + (5 * 161) + (15 * 160) • F3.A9 16 or 0xF3.A9 (15 * 161) + (3 * 160) + (10 * 16-1) + (9 * 16-2) Monday, January 11, 2010
    • Octal and Hexadecimal • Humans are accustomed to decimal • Computers use binary • So why ever use octal or hexadecimal? • Binary numbers can be long with a lot of digits • Longer number make for more confusion • Copying longer numbers allows greater chance for error • Octal represents binary in 1/3 the number of digits • Hexadecimal represents binary in 1/4 the number of digits Monday, January 11, 2010
    • Base Conversion Binary to Decimal • 11010 2 • (1*2 )+(1*2 )+(0*2 )+(1*2 )+(0*2 ) 4 3 2 1 0 • 16 + 8 + 0 + 2 + 0 • 26 Monday, January 11, 2010
    • Base Conversion Octal to Decimal • 1523 8 • (1*8 )+(5*8 )+(2*8 )+(3*8 ) 3 2 1 0 • 512+320+16+3 • 851 Monday, January 11, 2010
    • Base Conversion Hexadecimal to Decimal • B65F 16 • (11 * 16 ) + (6 * 16 ) + (5 * 16 ) + (15 * 16 ) 3 2 1 0 • 45056+1536+80+15 • 46687 Monday, January 11, 2010
    • Base Conversion Decimal to Binary • 25 / 2 = 12 R 1 (1101112) • 82310 • 12 / 2 = 6 R 0 (01101112) • 823 / 2 = 411 R1(12) • 6 / 2 = 3 R 0 (001101112) • 411 / 2 = 205 R 1 (112) • 3 / 2 = 1 R 1 (1001101112) • 205 / 2 = 102 R 1 (1112) • 1 / 2 = 0 R 1 (11001101112) • 102 / 2 = 51 R 0 (01112) • 11001101112 • 51 / 2 = 25 R 1 (101112) Monday, January 11, 2010
    • Base Conversion Decimal to Octal • 823 • 823 / 8 = 102 R 7 (7 ) 8 • 102 / 8 = 12 R 6 (67 ) 8 • 12 / 8 = 1 R 4 (467 ) 8 • 1 / 8 = 0 R 1 (1467 ) 8 • 1467 8 Monday, January 11, 2010
    • Base Conversion Decimal to Hexadecimal • 82310 • 250010 • 823 / 16 = 51 R 7 (716) • 2500 / 16 = 156 R 4 (416) • 51 / 16 = 3 R 3 (3716) • 156 / 16 = 9 R 12 (C416) • 3 / 16 = 0 R 3 (33716) • 9 / 16 = 0 R 9 (9C416) • 33716 • 9C416 Monday, January 11, 2010
    • Base Conversion Binary to Octal Octal to Binary • 11001101112 • 14678 • (12) (1002) (1102) (1112) • (18) (48) (68) (78) • (18) (48) (68) (78) • (0012) (1002) (1102) (1112) • 14678 • 11001101112 Monday, January 11, 2010
    • Base Conversion Binary to Hexadecimal to Hexadecimal Binary • 10110110010111112 • B65F16 • (10112) (01102) (01012) • (B16) (616) (516) (F16) (11112) • (10112) (01102) (01012) • (B16) (616) (516) (F16) (11112) • B65F16 • 10110110010111112 Monday, January 11, 2010
    • Computing Systems • Computers were originally designed for the primary purpose of doing numerical calculations. Abacus, counting machines, calculators • We still do numerical operations, but not necessarily as a primary function. • Computers are now “information processors” and manipulate primarily nonnumeric data. Text, GUIs, sounds, information structures, pointers to data addresses, device drivers Monday, January 11, 2010
    • Codes • A code is a scheme for representing information. • Computers use codes to store types of information. • Examples of codes: • Alphabet • DNA (biological coding scheme) • Musical Score • Mathematical Equations Monday, January 11, 2010
    • Codes • Two Elements (always) • A group of symbols • A set of rules for interpreting these symbols • Place-Value System (common) • Information varies based on location • Notes of a musical staff • Bits in a binary number Monday, January 11, 2010
    • Computers and Codes • Computers are built from two-state electronics. • Each memory location (electrical, magnetic, optic) has two states (On or Off) • Computers must represent all information using only two symbols • On (1) • Off (0) • Computers rely on binary coding schemes Monday, January 11, 2010 Quantum computing? Tertiary-state machines? Maybe, but not yet and/or not common. Probably coming, though.
    • Computers and Binary • Decimal 109 • Binary 11011012 • Computer 16-bit word size 0000 0000 0110 11012 • Computer 32-bit word size 0000 0000 0000 0000 0000 0000 0110 11012 Monday, January 11, 2010 Many modern computers now use a 64-bit word size in their CPUs. 231 ~ 4 billion. 263 ~ 9.2 quintillion (~1019). Also IP address sizes (v4 and v6).
    • Binary Addition • 4502 + 1234 • 1000110010110 2 + 100110100102 • 1011001101000 2 • 5736 11 1 11 10001100101102 00100110100102 10110011010002 Monday, January 11, 2010
    • Negative Numbers Sign-Magnitude Format • Uses the highest order bit as a ‘sign’ bit. All other bits are used to store the absolute value (magnitude) • Negative numbers have the sign bit set • Reduces the range of values that can be stored. • -109 in 16-bit representation using a sign bit 10 1000 0000 0110 11012 Monday, January 11, 2010
    • Negative Numbers One’s Complement Format • Exact opposite of the sequence for the positive value. Each bit is “complemented” or “flipped” • 109 in 16-bit representation 0000 0000 0110 11012 • -109 in 16-bit One’s Complement 1111 1111 1001 00102 • This makes mathematical operations difficult Monday, January 11, 2010
    • Negative Numbers Two’s Complement Format • Add 1 to One’s Complement • 109 in 16-bit representation 0000 0000 0110 11012 • -109 in 16-bit One’s Complement 1111 1111 1001 00102 • -109 in 16-bit Two’s Complement 1111 1111 1001 00112 Monday, January 11, 2010
    • Negative Numbers • -109 in 16-bit One’s Complement 1111 1111 1001 00102 • -109 in 16-bit Two’s Complement 1111 1111 1001 00102 + 0000 0000 0000 00012 1111 1111 1001 00112 Monday, January 11, 2010
    • Two’s Complement Shortcut • 109 in 16-bit representation 0000 0000 0110 11012 • -109 in 16-bit Two’s Complement: • Copy everything left of the first ‘1’ including the first ‘1’ 0000 0000 0110 11012 • Complement (flip) all other bits 1111 1111 1001 00112 Monday, January 11, 2010
    • Two’s Complement Shortcut • 10656 in 16-bit representation 0010 1001 1010 00002 • -10656 in 16-bit Two’s Complement: • Copy everything left of the first ‘1’ including the first ‘1’ 0010 1001 1010 00002 • Complement (flip) all other bits 1101 0110 0110 00002 Monday, January 11, 2010
    • Two’s Complement Arithmetic • 4502 + (-1234) Convert to binary, 16-bit representations 450210 0001 0001 1001 01102 -123410 + 1111 1011 0010 11102 10000 1100 1100 01002 • This is 17 bits – the highest order bit simply gets dropped! 00001100110001002 = 326810 Monday, January 11, 2010
    • utp ut O 01 00 11 00 1 11 00 00 00 6810 Inp ut 32 10 01 01 11 0 11 10 00 0 10 00 1 11 00 0 10 11 11 210 450 10 -1 234 Monday, January 11, 2010 Imagine that you are doing this operation in a silicon chip with only 16 pins on each side. The 17th “bit” has nowhere to go! In actuality, the input would be preceded by an “add” command.
    • Monday, January 11, 2010
    • Credits - CC Licensed Decimal numbers on shoji http://www.flickr.com/photos/pitmanra/1184492148/ Hands http://www.flickr.com/photos/faraz27989/537051865/ Clock http://www.flickr.com/photos/zoutedrop/2317065892/ Credits - Fair Use Linear A tablet http://www.historywiz.com/images/greece/lineara.jpg T-shirt http://www.thinkgeek.com/tshirts-apparel/unisex/frustrations/5aa9/zoom/ 8086 chip http://dl.maximumpc.com/galleries/x86/8086.png Monday, January 11, 2010