Lecture 11
Announcements
Exam 1: Tuesday, March 13
Today:
Bits, Bytes, and Binary II
What is a Bit?
0 and 1 are called Binary Digits
(or Bits)
View a bit as the fundamental unit
of storage on a computer.
Binary Number System: elements are 0,1
Decimal Number System: elements are
0,1,2,3,4,5,6,7,8,9
A single bit has limited usefulness: it can represent only two values (0 or 1) and hence can distinguish only between two states.
A Byte is an ordered string of 8 bits:
Examples:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
How many different Bytes are there?
How many different states can a byte
represent?
Two Bits: 22 = 4 possibilities
|
|
|
|
|
|
|
|
With 2 bits, we can represent
22 = 4
states
Three Bits: 23 = 8 possibilities
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
number of bits | number of states | Power of 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Each key has 2 positions -> ~ 210 different messages can be sent to the computer.
Now 27 = 128 and 28 = 256
7 bits would not suffice, but 8 will.
Thus there are enough bytes to distinguish 256 distinct objects.
One such set: the whole numbers from 0 to 255:
0,1,2,3,4,....,254,255
Is there an easy to do this?
Place Holder Notation!
Decimal Notation:
467 = 400 + 60 + 7
= 4 * 100 + 6 * 10 + 7 * 1
= 4 * 102 + 6 *101 + 7 * 100
1101 = 1 *103+ 1 * 102 + 0 * 101 + 1 * 100
Binary Notation
11012 = 1 * 23+ 1 * 22 + 0 * 21 + 1 * 20
= 8 + 4 +1 = 13
1 00000001
2 00000010
3 00000011
4 00000100
5 00000101
6 00000110
7 00000111
8 00001000
etc.
Powers of Two
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
2 | 4 | 8 | 16 | 32 | 64 | 128 | 256 | 512 | 1024 | 2048 | 4096 |
Find highest power of two less than the number
Subract that power
Repeat
1492 = 1024 + 468
= 1024 + 256 + 212
= 1024 + 256 + 128 + 84
= 1024 + 256 + 128 + 64 + 20
= 1024 + 256 + 128 + 64 + 16 + 4
1024 | 512 | 256 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
1 | 0 | 1 | 1 | 1 | 0 | 1 | 0 | 1 | 0 | 0 |
1 0 1 1 1 0 1 0 1 0 0
Which binary patterns should represet which keyboard elements?
American Standard Code for Information Interchange
(1963)
Windows, Macs and UNIX machines all use ASCII to store characters.
Larger IBM mainframes and minicomputers use the EBCDIC standard
(AS/400 stores your student records this way)
http://tronweb.super-nova.co.jp/characcodehist.html
A Brief History of Character Codes
in
North America, Europe, and East
Asia
Steven J. Searle
Although the ASCII character code was adopted by manufacturers of minicomputers, workstations, and personal computers in the U.S., and later turned into an international standard by the ISO, in the field of mainframe computers, IBM--the dominant force in the world of computing in the 1960s and 1970s--decided to go its own way.
This was most likely decided on the basis of concern for compatibility with past technology, but many people viewed it as primarily a marketing strategy to keep IBM customers locked into IBM hardware and software.
In any event, the company created a proprietary 8-bit character code (2^8 = 256 code points) called EBCDIC [pronounced eb-see-dick ], which stands for "Extended Binary Coded Decimal Interchange Code." It was used on the successful IBM System/360 mainframe computer series, which hit the market in April 1964. EBCDIC is an extension to 8 bits of BCDIC (Binary Coded Decimal Interchange Code), an earlier 6-bit binary code (2^6 = 64 code points) for IBM computers. (It should be noted that some sources refer to this previous 6-bit character code simply as BCD, or "Binary Coded Decimal," but BCD is also used to refer to a 4-bit character code [2^4 = 16 code points] for encoding Arabic numerals.)
ASCII/EBCDIC Comparsion: http://www.flash.net/~gwstern/ascii_ebcdic.html
Printable Characters
decimal | Character | decimal | Character | decimal | Character | ||
032 | (Space) | 064 | @ | 096 | ` | ||
033 | ! | 065 | A | 097 | a | ||
034 | " | 066 | B | 098 | b | ||
035 | # | 067 | C | 099 | c | ||
036 | $ | 068 | D | 100 | d | ||
037 | % | 069 | E | 101 | e | ||
038 | & | 070 | F | 102 | f | ||
039 | ' | 071 | G | 103 | g | ||
040 | ( | 072 | H | 104 | h | ||
041 | ) | 073 | I | 105 | i | ||
042 | * | 074 | J | 106 | j | ||
043 | + | 075 | K | 107 | k | ||
044 | , | 076 | L | 108 | l | ||
045 | - | 077 | M | 109 | m | ||
046 | . | 078 | N | 110 | n | ||
047 | / | 079 | O | 111 | o | ||
048 | 0 | 080 | P | 112 | p | ||
049 | 1 | 081 | Q | 113 | q | ||
050 | 2 | 082 | R | 114 | r | ||
051 | 3 | 083 | S | 115 | s | ||
052 | 4 | 084 | T | 116 | t | ||
053 | 5 | 085 | U | 117 | u | ||
054 | 6 | 086 | V | 118 | v | ||
055 | 7 | 087 | W | 119 | w | ||
056 | 8 | 088 | X | 120 | x | ||
057 | 9 | 089 | Y | 121 | y | ||
058 | : | 090 | Z | 122 | z | ||
059 | ; | 091 | [ | 123 | { | ||
060 | < | 092 | \ | 124 | | | ||
061 | = | 093 | ] | 125 | } | ||
062 | > | 094 | ^ | 126 | ~ | ||
063 | ? | 095 | _ | 127 | DEL |
065 | A | 097 | a | |
066 | B | 098 | b | |
067 | C | 099 | c | |
068 | D | 100 | d | |
069 | E | 101 | e | |
070 | F | 102 | f | |
... | ||||
088 | X | 120 | x | |
089 | Y | 121 | y | |
090 | Z | 122 | z |
Upper and lower case version of the
same letter are 32 apart.
F -> 70 = 64 + 4 + 2 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 1 |
f -> 92 = 64 + 32 + 4 + 2 | 0 | 1 | 1 | 0 | 0 | 1 | 1 | 1 |
Decinal | Value | |||||
000 | NUL | (Null char.) | 016 | DLE | (Data Link Escape) | |
001 | SOH | (Start of Header) | 017 | DC1 (XON) | (Device Control 1) | |
002 | STX | (Start of Text) | 018 | DC2 | (Device Control 2) | |
003 | ETX | (End of Text) | 019 | DC3 (XOFF) | (Device Control 3) | |
004 | EOT | (End of Transmission) | 020 | DC4 | (Device Control 4) | |
005 | ENQ | (Enquiry) | 021 | NAK | (Negative Acknowledgement) | |
006 | ACK | (Acknowledgment) | 022 | SYN | (Synchronous Idle) | |
007 | BEL | (Bell) | 023 | ETB | (End of Trans. Block) | |
008 | BS | (Backspace) | 024 | CAN | (Cancel) | |
009 | HT | (Horizontal Tab) | 025 | EM | (End of Medium) | |
010 | LF | (Line Feed) | 026 | SUB | (Substitute) | |
011 | VT | (Vertical Tab) | 027 | ESC | (Escape) | |
012 | FF | (Form Feed) | 028 | FS | (File Separator) | |
013 | CR | (Carriage Return) | 029 | GS | (Group Separator) | |
014 | SO | (Serial In)(Shift Out) | 030 | RS | (Request to Send)(Record Separator) | |
015 | SI | (Serial Out)(Shift Out) | 031 | US | (Unit Separator) |
Designers of PCs, Macs and UNIX machines chose
different ways to represent "carriage return"
PCs: 13 and 10 (Carriage return and line feed)
Macs: 13
UNIX: 10
Makes it tricky to exchange files.
What is a KB?
A kilobyte (1 KB) is defined as 210 = 1024 bytes.
1 KB = 210 bytes= 1024 ~ 1000 bytes
A megabyte (1 MB) is 210 kilobytes:
1 MB = 210 KB = 210 210 bytes
= 220 bytes = 1,048,576 bytes
~ 1,000,000 bytes.
Rough Conversion: 210 ~ 103
Example: 220 = 210 210 ~ 103 103 = 106
Computer Memory: 64 MB
Floppy Disk: 1.44 MB
Zip Disk: 100 MB
A gigabyte (1 GB) is 210 megabytes:
1 GB = 210 MB = 210 220 bytes
= 230 bytes = 1,073,741,824 bytes
~ 1,000,000,000 bytes. (1 billion bytes)
Storage Space on Hard Drive: 20GB
CD-ROM : 650 MB
Human Terms:
A densely packed single spaced typed sheet of paper = 60 lines @ 80 characters
= 4800 characters ~ 5 KB
Alice in Wonderland:
27,808 words
148,491 characters ~ 150 KB
Number Systems
Question: What does 100 mean?
Answer: The meaning depends on the base
Base 10:
(100)10
= 1 * 102 + 0 * 101
+ 0 * 100
Base 2
(100)2
= 1 * 22 + 0 * 21
+ 0 * 20
Base 5
(100)5 = 1 * 52 + 0 * 51 + 0 * 50
Available Digits:
Base 2: 0,1
Base 5: 0,1,2,3,4
Base 10: 0,1,2,3,4,5,6,7,8,9
Base 16: 0,1,2,3,5,6,7,8,9,?,?,?,?,?,?
Hexadecimal (Base 16)
0,1,2,3,5,6,7,8,9,A,B,C,D,E,F
Counting to 20
Base 10 | Base 2 | Base 5 | Base 16 |
1 | 1 | 1 | 1 |
2 | 10 | 2 | 2 |
3 | 11 | 3 | 3 |
4 | 100 | 4 | 4 |
5 | 101 | 10 | 5 |
6 | 110 | 11 | 6 |
7 | 111 | 12 | 7 |
8 | 1000 | 13 | 8 |
9 | 1001 | 14 | 9 |
10 | 1010 | 20 | A |
11 | 1011 | 21 | B |
12 | 1100 | 22 | C |
13 | 1101 | 23 | D |
14 | 1110 | 24 | E |
15 | 1111 | 30 | F |
16 | 10000 | 31 | 10 |
17 | 10001 | 32 | 11 |
18 | 10010 | 33 | 12 |
19 | 10011 | 34 | 13 |
20 | 10100 | 40 | 14 |
What is the decimal equivalent of the hexadecimal 2F?
2F = 2 * 161 + F * 160
= 32 + 15 = 47
Find Hexadecimal representation of 1492
Powers of 16: 16 256 4096 65536
1492 = 5 * 256 + 212
= 5 * 256 + 13 * 16 + 4
= 5 * 162 + D* 161 + 4 * 160
= 5D4