Download presentation
Presentation is loading. Please wait.
1
©Brooks/Cole, 2003 Chapter 2 Data Representation
2
©Brooks/Cole, 2003 Figure 2-1 Different types of data Computer programs can have different purposes: -Word processing program handles TEXT (move, delete, just) -Engineering program deals with NUMBERS (arithmetic equations,..) -Image processing program manipulate images (create, shrink, rotate,..) -Video player shows movie and handles audio data ( play music, voice.)
3
©Brooks/Cole, 2003 Figure 2-2 Bit pattern -All data types are represented using universal format called bit pattern which is a sequence or string of bits -A Bit (binary digit) is the smallest unit of data that can be stored in a computer; it is either 0 or 1 -An electronic switch can represent a bit. -Example of a 16 bit pattern -Computer memory stores the data as bit pattern and I/O devices or programs interpret bit patterns as needed into number, text, image, audio, video (multimedia). -Data are coded when they enter the computer and decoded when they are represented to user.
4
©Brooks/Cole, 2003 Figure 2-3 Examples of bit patterns
5
©Brooks/Cole, 2003 Figure 2-4 Representing symbols using bit patterns - A piece of TEXT in any language is a sequence of symbols used to represent an idea in that language. -ُ Each symbol can be represented by a bit pattern - TEXT such as BYTE can be represented as 4 bit pattern
6
©Brooks/Cole, 2003 - Logarithmic relationship between bit pattern length and number of symbols. Example: 2 symbols needs 1 bit (log 2 2) FormsNumber of Symbols Bit Pattern Length 0, 121 00, 01,10,1142 000,001,010,011,100,101,110,11183 0000,0001,0010,0011,0100,0101, 0110,0111,1000,1001,1010,1011 1100,1101,1110,1111 164 Representing symbols using bit patterns
7
©Brooks/Cole, 2003 Figure 2-5 Representation of the word “BYTE” in ASCII code - ASCII is the American Standard Code for Information Interchange and it has the following features: -Uses 7-bit pattern: 00000000 (null) to 01111111 (delete). 128 symbols can be represented. -There are 31 nonprintable character -Numeric characters are coded before letters -A, B….Z (upper letters) come before a, b,…., z (lowercase) and the sixth bit from right distinguishes them.
8
©Brooks/Cole, 2003 Representation of Symbols with other Codes - Extended ASCII uses 8-bits pattern instead of 7-bits to represent 256 symbols. - EBCDIC (Extended Binary Coded Decimal Interchange Code) uses 8-bits but it is only used on IBM computers. - UniCode uses 16-bits to represents 65,535 symbols. - ISO uses 32-bit pattern to represent 4,294,967,294 symbols.
9
©Brooks/Cole, 2003 Figure 2-6 Image representation methods - Bitmap graphic method divides an image into pixels (picture element which is a small dot. The resolution is the size of the pixels. As the resolution increases, the image quality will increase but more memory will be needed to store the image. - Vector graphics does not store the bit pattern of an image because an image will be represented using a mathematical formula which will be stored. An image is decomposed into a combination of curves and lines. Scaling is very easy.
10
©Brooks/Cole, 2003 Figure 2-7 Bitmap graphic method of a black-and-white image - Each pixel is assigned a bit pattern (0 for white, 1 for black) To show 4 levels of gray scale, a pixel is represented by a 2-bit pattern(00 black, 01 dark gray, 10 light dark gray, 11white)
11
©Brooks/Cole, 2003 Figure 2-8 Representation of color pixels - Each colored pixel is decomposed into red, green, blue. - Intensity of each color is measured and a bit pattern ( usually 8-bit) is assigned to it. - More memory is needed to store a colored image!!
12
©Brooks/Cole, 2003 Figure 2-9 Audio representation 1. Measure value of signal at equal intervals 2. Assign a value from a set to a sample 3. Store converted binary pattern
13
©Brooks/Cole, 2003 Figure 2-10 Binary to hexadecimal and hexadecimal to binary transformation A 4-bit pattern can be represented by a hexadecimal digit, and vice versa. Bit Pattern Bit Pattern ------------ 0000 0001 0010 0011 0100 0101 0110 0111 Hex Digit Hex Digit ------------ 0 1 2 3 4 5 6 7 Bit Pattern Bit Pattern ------------ 1000 1001 1010 1011 1100 1101 1110 1111 Hex Digit Hex Digit ------------ 8 9 A B C D E F
14
©Brooks/Cole, 2003 Example 1 Show the hexadecimal equivalent of the bit pattern 1100 1110 0010. Solution Each group of 4 bits is translated to one hexadecimal digit. The equivalent is xCE2.
15
©Brooks/Cole, 2003 Example 2 Show the hexadecimal equivalent of the bit pattern 0011100010. Solution Divide the bit pattern into 4-bit groups (from the right). In this case, add two extra 0s at the left to make the number of bits divisible by 4. So you have 000011100010, which is translated to x0E2.
16
©Brooks/Cole, 2003 Example 3 What is the bit pattern for x24C? Solution Write each hexadecimal digit as its equivalent bit pattern to get 001001001100.
17
©Brooks/Cole, 2003 Figure 2-11 Binary to octal and octal to binary transformation A 3-bit pattern can be represented by an octal digit, and vice versa. Bit Pattern Bit Pattern ------------ 000 001 010 011 Oct Digit Oct Digit ------------ 0 1 2 3 Bit Pattern Bit Pattern ------------ 100 101 110 111 Oct Digit Oct Digit ------------ 4 5 6 7
18
©Brooks/Cole, 2003 Example 4 Show the octal equivalent of the bit pattern 101110010. Solution Each group of 3 bits is translated to one octal digit. The equivalent is 0562, o562, or 562 8.
19
©Brooks/Cole, 2003 Example 5 Show the octal equivalent of the bit pattern 1100010. Solution Divide the bit pattern into 3-bit groups (from the right). In this case, add two extra 0s at the left to make the number of bits divisible by 3. So you have 001100010, which is translated to 142 8.
20
©Brooks/Cole, 2003 Example 6 What is the bit pattern for 24 8 ? Solution Write each octal digit as its equivalent bit pattern to get 010100.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.