chapter 2 digital data representation and … 2...• an analog or analogue signal is any variable...

30
CHAPTER 2 - DIGITAL DATA REPRESENTATION AND NUMBERING SYSTEMS

Upload: others

Post on 14-Mar-2020

13 views

Category:

Documents


0 download

TRANSCRIPT

CHAPTER 2-

DIGITAL DATA REPRESENTATIONAND

NUMBERING SYSTEMS

INTRODUCTION

• Digital computers use sequences of binarydigits (bits) to represent numbers, letters,special symbols, music, pictures, and videos.For this reason, we study the Digital DataRepresentation and Numbering System inorder to understand how computers storeinformation in Binary digits

TYPES OF SIGNAL - ANALOGUE SIGNAL

• An analog or analogue signal is any variable signal continuousin both time and amplitude.

• Analog signals are represented as sine wave. The sine wave'samplitude value can be seen as the higher and lower points ofthe wave, while the frequency (time) value is measured in thesine wave's physical length from left to right.

TYPES OF SIGNAL - ANALOGUESIGNAL

Examples of analog signals:A good example of an analogue signal is the loud-

speaker of a stereo system. When the volume isturned up, the sound increases slowly andconstantly.The sound from a human voice is analog, because

sound waves are continuous,Even a typical kitchen clock having its hands

moving continuously can be represented as ananalog signal

TYPES OF SIGNAL - DIGITALSIGNAL

Digital Signal is discrete signal in both time and amplitude. Adigital signal refers to an electrical signal that is converted intoa pattern of bits. These patterns can be generated in manyways, each producing a specific code.

digital signals can take only a limited number of values(discrete steps); usually just two values are used: the positivesupply voltage (+Vs) and zero volts (0V).

TYPES OF SIGNAL - DIGITALSIGNAL

Logical States

+Vs 0Vs

True False

On Off

High Low

1 0

ANALOGUE TO DIGITAL CONVERTOR(ADC)

If you want to attach an analogue input device to adigital device such as a computer, you will need an analogue todigital convertor(ADC).

A good example of a computer peripheral that requires anADC is a microphone.

When you plug a microphone into a computer, you areactually plugging it into an ADC which converts theanalogue signals from the microphone into digital data that thecomputer 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 toanalogue convertor(DAC).

• A good example of a computer peripheral that requires aDAC is a loud speaker or headphones.

• When you plug a loudspeaker into a computer , you areactually plugging it into a DAC, which takes digitaldata 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 playerproduces analogue signals which the headphones convert intosound.

Note:• The ADC and DAC in a computer that are used for connecting

microphones and loud speakers are part of the computer’ssound card.

Data Representation-Text/CharacterData Representation

• Any piece of data that is stored in a computer’s memory mustbe stored as a binary number. Data is not just alphabeticcharacters, but also numeric characters, punctuation, spaces,etc.

• When a character is stored in memory, it is first converted to anumeric code. The numeric code is then stored in memory as abinary number

• Historically, the most important of these coding schemes isASCII, which stands for the American Standard Code forInformation Interchange. It is the most commonly used codingtechnique for alphanumeric data.

Data Representation-Text/CharacterData Representation

• Old version of ASCII characters are represented in 7 bits. So27=128 numeric codes, those represent the English letters,various punctuation marks, and other characters. Extendedversion of ASCII characters are represented in 8 bits. So28=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 is49 and so on

• ASCII is limited however, because it defines codes for only128 or 256 characters. To remedy this, the Unicode characterset was developed in the early 1990s.

Data Representation-Text/CharacterData Representation

• Unicode (Universal Code) is an extensive encodingscheme that is compatible with ASCII, but can alsorepresent characters for many of the natural languages inthe world. The Unicode character set uses 16 bits percharacter.

• Therefore, the Unicode character set can represent216=65,536 characters. Unicode was designed to be asuperset of ASCII. That is, the first 256 characters in theUnicode character set correspond exactly to the extendedASCII character set.

• Today, Unicode is quickly becoming the standardcharacter set used in the computer industry

Data Representation-Images andGraphics

• Digitizing a picture is the act of representing it as acollection of individual dots called pixels (Pictureelements). Each pixel is assigned a tonal value (black,white, shades of gray or color), which is representedin binary code (zeros and ones).

• The number of pixels used to represent a picture iscalled the resolution. Resolution is usually expressedby numbers for horizontal and vertical: 640 by 480means 640 pixels wide, by 480 pixels tall.

• The storage of image information on a pixel-by-pixelbasis is called a raster-graphics format. Mostpopular raster file formats are: JPEG, GIF, BMP,TIFF, PCX and PNG.

Data Representation-Images andGraphics

• Color is our perception of the various frequencies oflight that reach the retinas of our eyes.

• Color is often expressed in a computer as an RGB(red-green-blue) value, which is actually threenumbers that indicate the relative contribution of eachof these three primary colors.

• For example, an RGB value of (255, 255, 0)maximizes the contribution of red and green, andminimizes the contribution of blue, which results in abright yellow.

Data Representation-Sound/Audio

• Sound is perceived when a series of aircompressions vibrate a membrane in ourear, which sends signals to our brain.

• Several popular formats are: WAV, AU,AIFF, VQF, and MP3. Currently, thedominant format for compressing audiodata is MP3

Data Representation - Video/Animation

• What is video?– is the technology of electronically capturing,

recording, processing, storing, transmittingand reconstruction a sequence of still imagesrepresenting scenes in motion

– It is a collection of still images

• Common video codec’s formats are: AVI,MOV, MPEG (Moving Pictures Expert Group)and MP4

NUMBERING SYSTEM

• A number system is the set of symbols used to expressquantities as the basis for counting, determining order,comparing amounts, performing calculations, and representingvalue. Examples of numbering systems are decimal, binary,hexadecimal and octal numbering system.

• In order to represent numbers of different bases, we surround anumber in parenthesis and then place a subscript with the baseof 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

• The decimal number system is used in our everyday life. It hasvalues from 0 – 9. Decimal number system has a base of 10.

• This means that each digit in the number is multiplied by 10raised to a power corresponding to that digit’s position.

(4928)10

8 x 100 = 8x12 x 101 = 1x109 x 102 = 9x1004 x 103 = 4x100

Binary Number System

• Binary is a number system used by digital devices likecomputers. In the binary system, there are only two digits, 0and 1. The binary system is said to have a base of 2.

(1001)2

1 x 20 = 1x10 x 21 = 0x20 x 22 = 0x41 x 23 = 1x8

Octal Number System

• Octal number system is a numeral system witha base of 8. The values are represented by 0-7.Each octal digit represents three (3) binarybits.

Hexadecimal Number System

• Hexadecimal number system is a numeralsystem with a base of 16. The values arerepresented by 0-9, A,B,C,D,E,F. Eachhexadecimal digit represents four (4) binarybits

Numbers with Different Base

Decimal Numbers(Base 10)

Binary Numbers( Base 2)

Octal Numbers(Base 8)

Hexadecimal Numbers(Base 16)

0 0000 00 01 0001 01 12 0010 02 23 0011 03 34 0100 04 45 0101 05 56 0110 06 67 0111 07 78 1000 10 89 1001 11 910 1010 12 A11 1011 13 B12 1100 14 C13 1101 15 D14 1110 16 E15 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 usuallyindicate the “on” state with 1 and the “off” state with 0.These 1’s and 0’s are referred to as “bits” which is anabbreviation 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 numberssystem. Binary is the language of computers.

Converting Decimal Numbers to BinaryNumbers

Example 1: Convert the decimal number (35)10 to binary ( ? )2

2 352 17 ------12 8 ------12 4 ------02 2 ------0

1 ------0

• ANS: (35)10 = (100011)2

Converting Decimal Numbers to BinaryNumbers

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 --> 00.640 * 2 = 1.280 --> 10.280 * 2 = 0.560 --> 00.560 * 2 = 1.120 --> 10.120 * 2 = 0.240 --> 00.240 * 2 = 0.480 --> 00.480 * 2 = 0.960 --> 00.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 Decimalnumbers

Conversion of a binary number to its equivalent decimal number is done byaccumulating the multiplication of each digit of the binary number by Base 2of 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 significantdigit to be assigned location 0, next to it location 1 until digit 1 at the mostsignificant 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 Decimalnumbers

• Example 2:

• What is the decimal number of (100101)2

Converting Binary numbers to Decimalnumbers

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, ormathematical calculations: addition, subtraction,multiplication, division and modulus (remainder of division).Let us see the example of how binary addition done by theALU.

• Binary addition

INPUT OUTPUTA B A+B0 0 00 1 11 0 11 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