CHAPTER 2 - DIGITAL DATA REPRESENTATION AND NUMBERING SYSTEMS
INTRODUCTION Digital computers use sequences of binary digits (bits) to represent numbers, letters, special symbols, music, pictures, and videos. For this reason, we study the Digital Data Representation and Numbering System in order to understand how computers store information in Binary digits
TYPES OF SIGNAL - ANALOGUE SIGNAL An analog or analogue signal is any variable signal continuous in both time and amplitude. Analog signals are represented as sine wave. The sine wave's amplitude value can be seen as the higher and lower points of the wave, while the frequency (time) value is measured in the sine wave's physical length from left to right.
TYPES OF SIGNAL - ANALOGUE SIGNAL Examples of analog signals: A good example of an analogue signal is the loud-speaker of a stereo system. When the volume is turned up, the sound increases slowly and constantly. The sound from a human voice is analog, because sound waves are continuous, as is our vision, because we see various shapes and colors in a continuous manner due to light waves. The sound waves that your mouth produces when you speak are analogue - the waves vary in a smooth way. These waves can be converted into an electrical signal by a microphone. This electrical signal is also analogue. Even a typical kitchen clock having its hands moving continuously can be represented as an analog signal
TYPES OF SIGNAL - DIGITAL SIGNAL Digital Signal is discrete signal in both time and amplitude. A digital signal refers to an electrical signal that is converted into a pattern of bits. These patterns can be generated in many ways, each producing a specific code. Digital systems process digital signals which can take only a limited number of values (discrete steps); usually just two values are used: the positive supply voltage (+Vs) and zero volts (0V).
TYPES OF SIGNAL - DIGITAL SIGNAL This digital signal is called a logic signal because they have only two values (or states) either true or false. Normally the positive supply voltage +Vs represent true and 0V represents false. Other labels for the true and false states are shown in the following table. Computers (and most other modern electronic devices such as cameras, mobile phones, etc.) are ‘digital’ devices because they process data in the form of binary numbers (0,1). Logical States +Vs 0Vs True False On Off High Low 1
ANALOGUE TO DIGITAL CONVERTOR (ADC) If you want to attach an analogue input device to a digital device such as a computer, you will need an analogue to digital convertor(ADC). A good example of a computer peripheral that requires an ADC is a microphone. When you plug a microphone into a computer, you are actually plugging it into an ADC which converts the analogue signals from the microphone into digital data that the computer can then process.
Digital to Analogue Convertor (DAC) If you want to attach an analogue output device to a digital device such as a computer, you will need a digital to analogue convertor(DAC). A good example of a computer peripheral that requires a DAC is a loud speaker or headphones. When you plug a loudspeaker into a computer , you are actually plugging it into a DAC, which takes digital data from the computer and converts it into analogue signals which the loudspeaker then converts into sound.
Digital to Analogue Convertor (DAC) Another device that contains a DAC is an MP3 player. The music data stored in the player is all digital, but the player produces analogue signals which the headphones convert into sound. Note: The ADC and DAC in a computer that are used for connecting microphones and loud speakers are part of the computer’s sound card.
Data Representation-Text/Character Data Representation Any piece of data that is stored in a computer’s memory must be stored as a binary number. Data is not just alphabetic characters, but also numeric characters, punctuation, spaces, etc. When a character is stored in memory, it is first converted to a numeric code. The numeric code is then stored in memory as a binary number Historically, the most important of these coding schemes is ASCII, which stands for the American Standard Code for Information Interchange. It is the most commonly used coding technique for alphanumeric data.
Data Representation-Text/Character Data Representation Old version of ASCII characters are represented in 7 bits. So 27=128 numeric codes, those represent the English letters, various punctuation marks, and other characters. Extended version of ASCII characters are represented in 8 bits. So 28=256 numeric codes are used for alphanumeric characters. ASCII value for ‘A’ is 65; ‘B’ is 66 and so on. ASCII value for ‘a’ is 97 and ‘b’ is 98 and so on. ASCII value for 0 is 48, 1 is 49 and so on ASCII is limited however, because it defines codes for only 128 or 256 characters. To remedy this, the Unicode character set was developed in the early 1990s.
Data Representation-Text/Character Data Representation Unicode (Universal Code) is an extensive encoding scheme that is compatible with ASCII, but can also represent characters for many of the natural languages in the world. The Unicode character set uses 16 bits per character. Therefore, the Unicode character set can represent 216=65,536 characters. Unicode was designed to be a superset of ASCII. That is, the first 256 characters in the Unicode character set correspond exactly to the extended ASCII character set. Today, Unicode is quickly becoming the standard character set used in the computer industry
Data Representation-Images and Graphics Digitizing a picture is the act of representing it as a collection of individual dots called pixels (Picture elements). Each pixel is assigned a tonal value (black, white, shades of gray or color), which is represented in binary code (zeros and ones). The binary digits ("bits") for each pixel are stored in a sequence by a computer and often reduced to a mathematical representation (compressed). The bits are then interpreted and read by the computer to produce an analog version for display or printing. The number of pixels used to represent a picture is called the resolution. Resolution is usually expressed by numbers for horizontal and vertical: 640 by 480 means 640 pixels wide, by 480 pixels tall. Multiply the numbers and you get the total number of pixels. In this case 640x480 = 307,200. The storage of image information on a pixel-by-pixel basis is called a raster-graphics format. Most popular raster file formats are: JPEG, GIF, BMP, TIFF, PCX and PNG.
Data Representation-Images and Graphics Color is our perception of the various frequencies of light that reach the retinas of our eyes. Our retinas have three types of color photoreceptor cone cells that respond to different sets of frequencies. These photoreceptor categories correspond to the colors of red, green, and blue. Color is often expressed in a computer as an RGB (red-green-blue) value, which is actually three numbers that indicate the relative contribution of each of these three primary colors. For example, an RGB value of (255, 255, 0) maximizes the contribution of red and green, and minimizes the contribution of blue, which results in a bright yellow.
Data Representation-Images and Graphics The amount of data that is used to represent a color is called the color depth. HiColor is a term that indicates a 16-bit color depth. Five bits are used for representing the R and B components. Six bits are used for representing the G component, because the human eye is more sensitive to G. TrueColor indicates a 24-bit color depth. Therefore, each number in an RGB value is represented using eight bits
Data Representation-Sound/Audio Sound is perceived when a series of air compressions vibrate a membrane in our ear, which sends signals to our brain. A stereo sends an electrical signal to a speaker to produce sound. This signal is an analog representation of the sound wave. The voltage in the signal varies in direct proportion to the sound wave. To digitize the signal we periodically measure the voltage of the signal and record the appropriate numeric value. The process is called sampling. In general, a sampling rate of around 40,000 times per second is enough to create a very good high quality sound reproduction Several popular formats are: WAV, AU, AIFF, VQF, and MP3. Currently, the dominant format for compressing audio data is MP3
Data Representation - Video/Animation What is video? is the technology of electronically capturing, recording, processing, storing, transmitting and reconstruction a sequence of still images representing scenes in motion It is a collection of still images Frame rate: the number of still images (or frames) recorded every second. Usually frame rate is expressed in frames per second (fps) and most video cameras record at 30 fps. Digital video: is composed of a series of frames. Each time is essentially a still picture, which could be represented using the same techniques as a bitmapped picture. Codec - compression/decompression format often used for digital video. Common video codec’s are: AVI, MOV, MPEG (Moving Pictures Expert Group) and MP4
NUMBERING SYSTEM A number system is the set of symbols used to express quantities as the basis for counting, determining order, comparing amounts, performing calculations, and representing value. Examples of numbering systems are decimal, binary, hexadecimal and octal numbering system. In order to represent numbers of different bases, we surround a number in parenthesis and then place a subscript with the base of the number. A decimal number is written (9233)10 A binary number is written (11011)2 An octal number is written (7133)8 A hexadecimal number is written (2BC1)16g system
DECIMAL NUMBER SYSTEM (4928)10 8 x 100 = 8x1 2 x 101 = 1x10 The decimal number system is used in our everyday life. It has values from 0 – 9. Decimal number system has a base of 10. This means that each digit in the number is multiplied by 10 raised to a power corresponding to that digit’s position. (4928)10 8 x 100 = 8x1 2 x 101 = 1x10 9 x 102 = 9x100 4 x 103 = 4x100
Binary Number System (1001)2 1 x 20 = 1x1 0 x 21 = 0x2 0 x 22 = 0x4 Binary is a number system used by digital devices like computers. In the binary system, there are only two digits, 0 and 1. The binary system is said to have a base of 2. (1001)2 1 x 20 = 1x1 0 x 21 = 0x2 0 x 22 = 0x4 1 x 23 = 1x8
Octal Number System Octal number system is a numeral system with a base of 8. The values are represented by 0-7. Each octal digit represents three (3) binary bits.
Hexadecimal Number System Hexadecimal number system is a numeral system with a base of 16. The values are represented by 0-9, A,B,C,D,E,F. Each hexadecimal digit represents four (4) binary bits
Numbers with Different Base Decimal Numbers (Base 10) Binary Numbers ( Base 2) Octal Numbers (Base 8) Hexadecimal Numbers (Base 16) 0000 00 1 0001 01 2 0010 02 3 0011 03 4 0100 04 5 0101 05 6 0110 06 7 0111 07 8 1000 10 9 1001 11 1010 12 A 1011 13 B 1100 14 C 1101 15 D 1110 16 E 1111 17 F
Why we study binary number system? Most computers use the simple type of digital technology. Their electronic circuits have only two possible states “on” and “off”. When discussing these states, we usually indicate the “on” state with 1 and the “off” state with 0. These 1’s and 0’s are referred to as “bits” which is an abbreviation to “binary digits”. The above picture represents 01001101. When data is input into a computer, the numbers or words we understand are translated into a binary numbers system. Binary is the language of computers.
Why we study binary number system? Everything you type, input, output, send, retrieve, draw and so on is, in the end, converted to the computer’s native language: binary. The CPU consists of an Arithmetic and Logic Unit (ALU) where arithmetic and logical operations take place. ALU process these 0’s and 1’s and producing the results in the form of Binary numbers. These binary results are again converted to normal form and then given to output devices. To understand the conversion of normal input data to 0’s and 1’s, we are going to study the Decimal numbers to Binary Number conversion. To understand the operations of ALU (Arithmetic and Logic Unit) such as arithmetic operations (addition, subtraction multiplication and division) and Logical operations (AND, OR, NOT, XOR) we are going to study only the addition of Binary numbers and all these Logical operations. To understand the conversion of these resulted binary digits to normal form, we are going to study the Binary Number to Decimal Number conversion.
Converting Decimal Numbers to Binary Numbers Example 1: Convert the decimal number (35)10 to binary ( ? )2 2 35 2 17 ------1 2 8 ------1 2 4 ------0 2 2 ------0 1 ------0 ANS: (35)10 = (100011)2
Converting Decimal Numbers to Binary Numbers Example 2: Convert the decimal number (35.320)10 to its equivalent binary ( ? )2 We know the integer part is (35)10 = (100011)2 Fraction part is (0.320)10 0.320 * 2 = 0.640 --> 0 0.640 * 2 = 1.280 --> 1 0.280 * 2 = 0.560 --> 0 0.560 * 2 = 1.120 --> 1 0.120 * 2 = 0.240 --> 0 0.240 * 2 = 0.480 --> 0 0.480 * 2 = 0.960 --> 0 0.960 * 2 = 1.920 --> 1 (0.320)10= (0.010100001)2 So combining integer and fraction part, Answer is (35.320)10=(100011.010100001)2
Converting Binary numbers to Decimal numbers Conversion of a binary number to its equivalent decimal number is done by accumulating the multiplication of each digit of the binary number by Base 2 of power equal to the location of the digit in the binary number. Least significant digit (LSD) Most significant digit (MSD) Location 0 Location 4 Example 1: convert the binary number (11011 )2 to decimal number ( ? )10 We give the each digit a location number. We start from the least significant digit to be assigned location 0, next to it location 1 until digit 1 at the most significant digit location which it has to be assigned location 4. (11011)2 = 1 × 24 + 1 × 23 + 0 × 22 + 1 × 21 + 1 × 20 = 16 + 8 + 0 + 2 + 1 = (27)10 Answer is (11011)2 = (27)10
Converting Binary numbers to Decimal numbers Example 2: What is the decimal number of (100101)2
Converting Binary numbers to Decimal numbers Example 3: Convert (101.101)2 = ( ? )10 = 101.101 = 1 × 22 + 0 × 21 + 1 × 20 + 1 × 2-1 + 0 × 2-2 + 1 × 2-3 = 4 + 0 + 1 + 1/2 + 0 + 1/8 = 5 + 0.5 + 0.125 = 5.625 Answer is (101.101)2 = (5.625)10
Arithmetic operations-Binary Addition The ALU can perform five kinds of arithmetic operations, or mathematical calculations: addition, subtraction, multiplication, division and modulus (remainder of division). Let us see the example of how binary addition done by the ALU. Binary addition INPUT OUTPUT A B A+B 1 10 (0 with Carry 1)
Arithmetic operations-Binary Addition What is the Binary addition of (101)2 + (1001)2 What is the Binary addition of (111010)2 + (11011)2
Binary operations and logic gates The ALU also performs logical operations like the comparisons; it can compare numbers, letters, or special characters. For example (a=b,a<b, a>b, a>=b), the computer can then take action based on the result of the comparison. Boolean operator is an operation that manipulates one or more 0/1 values. ALU also performs some Boolean operations such as AND, OR, NOT and XOR by using logical gates. The electronic device which is used to implement the Boolean operations is called logic gates. Pictorial representation of logic gates are.
Binary operations and logic gates INPUT OUTPUT A B A AND B 1 INPUT OUTPUT A B A OR B 1
Binary operations and logic gates INPUT OUTPUT A B A XOR B 1 INPUT OUTPUT 1
Binary operations and logic gates Example 1: Almost all operations of computers can be carried out by logic gates Example: “one bit adder” One bit adder has two inputs and two outputs (S:sum, C: carry)
Binary operations and logic gates One Bit Adder Truth Table Circuit Compare it to the truth table of Boolean function AND, OR, XOR, NOT S = A .XOR. B C = A .AND. B A B S C 1
Binary operations and logic gates Example 2: In the above Circuit, A=0, B=1, C=1 and D=1. Find the output. If A=0 and B=1, then E=0 If C=1 and D=1 then F=1 E=0 and F=1 the Answer is 0
Binary operations and logic gates Example 3: In the above circuit A=1, B=0, C=1 and D=1 then Find E. Answer is: E=1