1 COMS 161 Introduction to Computing Title: The Digital Domain Date: September 6, 2004 Lecture Number: 6
2 Announcements Homework 3 –Due on Friday, 09/10/04
3 Review Digital information –Advantages Number system –Non-positional –Positional Decimal Octal Binary
4 Outline Binary numbers
5 Binary Number System Since binary digits have two possible values they are called bits –They only contain a little “bit” of information –Numbers represented in binary form will (most likely) require more digits (bits) than the decimal form
6 Binary Number System Number of Bits Number of Values To represent more information –Lump together multiple bits called strings
7 Binary Number System In general number of values = 2 number of bits How does 1 bit represent 2 values? –It can have one of two values 0, 1 –Can represent two colors, black and white –0: black –1: white Can represent two numbers: 0, 1
8 Binary Number System How do 2 bits represent 4 values? Bit PatternNumeric Value Item Represented 000Black 011White 102Red 113Green
9 Binary Number System How do 3 bits represent 8 values? Bit PatternNumeric ValueItem Represented 0000Black 0011White 0102Red 0113Green 1004Blue 1015Purple 1106Magenta 1117Sky blue
10 Binary Number System How do 4 bits represent 16 values? Bit PatternValueBit PatternValue
11 Binary Number System Bit patterns and numeric values are consistent with other slides –Acceptable to add leading 0’s if desired
12 Binary Number System We can represent the non-negative numbers (unsigned number) How about representing negative numbers? –Let the left most bit represent the sign (+, -) of the number –Called signed magnitude representation –[s][mag] 0 – 2 number of bits - 1
13 Signed Magnitude –One less bit to represent the magnitude
14 Signed Magnitude Problems –Two values of 0 More difficult to detect than one value of 0 –Incorrect arithmetic 2 – 1 = 2 + (-1) = 1
15 Two’s Complement Representation Sign bit in a sense –Positive numbers The leading bit (left most) is zero The same as signed magnitude –Negative numbers The leading bit is one Defined so that when added to their corresponding positive number the answer is zero
16 Bit PatternValueBit PatternValue Two’s Complement Representation
17 Two’s Complement Representation Problems with signed magnitude representation are solved with the two’s complement representation –There is only value of zero –Arithmetic is correct Solution is in two’s complement form 2 – 1 = 2 + (-1) = 1
18 Binary Encoding Unsigned binary numbers are useful when labeling things Common grouping –4 bits: nibble –8 bits: byte One byte represents 256 different values or items
19 Binary Number System –Letters in the English language A = = B = = … Z = = … a = = … Z = = Numbers are still left over for punctuation
20 Binary Number System Precision –The number of bits used to represent an item Letter: precision of 8 bits Integer (whole number): precision of 32 or 64 bits –Always finite Computers have finite precision –Presents some limitations
21 Hexadecimal Number System Sometimes called hex –Positional,base-16 system –Each digit is multiplied by a power of 16 –Sixteen unique symbols (digits) 0, 1, 2, …, 15 Symbol a or A for 10 Symbol b or B for 11 Symbol e or E for 14 Symbol c or C for 12 Symbol f or F for 15 Symbol d or D for 13
22 Hexadecimal Number System A hex number can represent 16 different items –Equivalent to 4 bits –Makes it easy to convert between binary and hex Group bits by 4’s from the left end Substitute the hex symbol –90 10 = = 5A 16 »Is the base 16 really needed? –66 10 = = 42 16
23 Hexadecimal Number System Use the backwards conversion to convert hex to binary –One hex digit is equivalent to 4 bits –Substitute the binary nibble Always start at the right end Add zeros to the left end as necessary to fill in 4 bits
24 Hexadecimal Number System HEXDECBIN A B C D E F151111
25 Digitization The process of converting analog information into binary –Discrete forms are unambiguous Text and numbers are discrete –Conversion of discrete to digital Come up with a mapping –As we did with the letters
26 Binary Coded Decimal Integers (whole numbers) –One mapping is to use its binary equivalent Binary Coded Decimal (BCD) –0 10 = –1 10 = – … –9 10 = Need a minimum of 4 bits to represent 10 different values –Some 4 bit quantities are wasted
27 Binary Coded Decimal String of decimal digits –Each decimal digit is represented by 4 bits –The number of bits needed to represent different numbers vary –Performing arithmetic is complicated
28 Digitizing Analog Information Two steps –Sampling the information Select discrete samples that represents the information –Quantizing the samples Discrete samples are measured Encoded into a binary representation
29 Digitizing Analog Information Sampling –In time or space (picture) Quantizing –Approximating the measured value
30 Images are digitized using a two step process Sampling the continuous tone image Quantizing the samples Digitizing Images
31 Sample image by pixel resolution Spatial Sampling Sample two- dimensional space Sampling Images
32 All gray values in each sample are averaged Quantizing Images
33 Different amount of sampling Quantizing Images
34 Different amount of sampling Quantizing Images
35 Different amount of sampling Quantizing Images