1. Number Systems
Spring 2010
Dr. David Hyland-Wood
University of Mary Washington
Monday, January 11, 2010
2. 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
3. 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.
8. 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.
9. “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.
10. “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.
11. “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.
12. “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.
13. “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.
15. 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
16. 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
25. 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
26. 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
27. 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
28. 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.
29. 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).
31. 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
32. 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
33. 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
35. 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
36. 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
37. 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
38. 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.