59
Lesson 1 Basic Theory of Information

Lesson 1 basic theory of information

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Lesson 1   basic theory of information

Lesson 1

Basic Theory of Information

Page 2: Lesson 1   basic theory of information

Number System

Number It is a symbol representing a unit or quantity.

Number System Defines a set of symbols used to represent

quantity Radix

The base or radix of number system determines how many numerical digits the number system uses.

Page 3: Lesson 1   basic theory of information

Types of Number System

Decimal System Binary Number System Octal Number System Hexadecimal Number System

Page 4: Lesson 1   basic theory of information

Decimal Number System

Ingenious method of expressing all numbers by means of tens symbols originated from India. It is widely used and is based on the ten fingers of a human being.

It makes use of ten numeric symbols 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

Page 5: Lesson 1   basic theory of information

Inherent Value and Positional Value

The inherent value of a symbol is the value of that symbol standing alone. Example 6 in number 256, 165, 698

The symbol is related to the quantity six, even if it is used in different number positions

The positional value of a numeric symbol is directly related to the base of a system. In the case of decimal system, each position has a

value of 10 times greater that the position to its right. Example: 423, the symbol 3 represents the ones (units), the symbol 2 represents the tens position (10 x 1), and the symbol 4 represents the hundreds position (10 x 10). In other words, each symbol move to the left represents an increase in the value of the position by a factor of ten.

Page 6: Lesson 1   basic theory of information

Inherent and Positional Value cont.

2539 = 2X1000 + 5X100 + 3X10 + 9X1

= 2X103 + 5X102 + 3X101 + 9 x100

This means that positional value of symbol 2 is 1000 or using the base 10 it is 103

Page 7: Lesson 1   basic theory of information

Binary Number System

Uses only two numeric symbols 1 and 0 Under the binary system, each position has a

value 2 times greater than the position to the right.

Page 8: Lesson 1   basic theory of information

Octal Number System

Octal number system is using 8 digits to represent numbers. The highest value = 7. Each column represents a power of 8. Octal numbers are represented with the suffix 8.

Page 9: Lesson 1   basic theory of information

Hexadecimal Number System

Provides another convenient and simple method for expressing values represented by binary numerals.

It uses a base, or radix, of 16 and the place values are the powers of 16.

Page 10: Lesson 1   basic theory of information

Decimal Binary Hexadecimal Decimal Binary Hexadecimal

0 0000 0 8 1000 8

1 0001 1 9 1001 9

2 0010 2 10 1010 A

3 0011 3 11 1011 B

4 0100 4 12 1100 C

5 0101 5 13 1101 D

6 0110 6 14 1110 E

7 0111 7 15 1111 F

Page 11: Lesson 1   basic theory of information

Radix Conversion

The process of converting a base to another. To convert a decimal number to any other

number system, divide the decimal number by the base of the destination number system. Repeat the process until the quotient becomes zero. And note down the remainders in the reverse order.

To convert from any other number system to decimal, take the positional value, multiply by the digit and add.

Page 12: Lesson 1   basic theory of information

Radix Conversion

Page 13: Lesson 1   basic theory of information

Radix Conversion

Page 14: Lesson 1   basic theory of information

Decimal to Binary Conversion of Fractions

Division – Multiplication Method Steps to be followed

Multiply the decimal fraction by 2 and noting the integral part of the product

Continue to multiply by 2 as long as the resulting product is not equal to zero.

When the obtained product is equal to zero, the binary of the number consists of the integral part listed from top to bottom in the order they were recorded.

Page 15: Lesson 1   basic theory of information

Example 1: Convert 0.375 to its binary equivalent

Multiplication Product Integral part

0.375 x 2 0.75 0

0.75 x 2 1.5 1

0.5 x 2 1.0 1

0.37510 is equivalent to 0.0112

Page 16: Lesson 1   basic theory of information

Exercises

Convert the following decimal numbers into binary and hexadecimal numbers:1. 128

2. 207 Convert the following binary numbers into

decimal and hexadecimal numbers:1. 11111000

2. 1110110

Page 17: Lesson 1   basic theory of information

Binary Arithmetic

Addition Subtraction Multiplication Division

Page 18: Lesson 1   basic theory of information

Binary Addition

1 + 1 = 0 plus a carry of 1 0 + 1 = 1 1 + 0 = 1 0 + 0 = 0

Page 19: Lesson 1   basic theory of information

Binary Subtraction

0 – 0 = 0 1 – 0 = 1 1 – 1 = 0 0 – 1 = 1 with borrow of 1

Page 20: Lesson 1   basic theory of information

Binary Multiplication

0 x 0 = 0 0 x 1 = 0 1 x 0 = 0 1 x 1 =1

Page 21: Lesson 1   basic theory of information

Data Representation

Data on digital computers is represented as a sequence of 0s and 1s. This includes numeric data, text, executable files, images, audio, and video.

Data can be represented using 2n Numeric representation

Fixed point Floating point

Non numeric representation 

Page 22: Lesson 1   basic theory of information

Fixed Point

Integers are whole numbers or fixed-point numbers with the radix point fixed after the least-significant bit.

Computers use a fixed number of bits to represent an integer. The commonly-used bit-lengths for integers are 8-bit, 16-bit, 32-bit or 64-bit.

Two representation

Page 23: Lesson 1   basic theory of information

Fixed Point: Two Representation Schemes

Unsigned Magnitude Signed Magnitude One’s complement Two’s complement

Page 24: Lesson 1   basic theory of information

Unsigned magnitude

Unsigned integers can represent zero and positive integers, but not negative integers.

Example 1: Suppose that n=8 and the binary pattern is 0100 0001, the value of this unsigned integer is 1×2^0 + 1×2^6 = 65.

Example 2: Suppose that n=16 and the binary pattern is 0001 0000 0000 1000, the value of this unsigned integer is 1×2^3 + 1×2^12 = 4104.

An n-bit pattern can represent 2^n distinct integers. An n-bit unsigned integer can represent integers from 0

to (2^n)-1

Page 25: Lesson 1   basic theory of information

Signed magnitude

The most-significant bit (msb) is the sign bit, with value of 0 representing positive integer and 1 representing negative integer.

The remaining n-1 bits represents the magnitude (absolute value) of the integer. The absolute value of the integer is interpreted as "the magnitude of the (n-1)-bit binary pattern".

Page 26: Lesson 1   basic theory of information

Signed magnitude

Example 1: Suppose that n=8 and the binary representation is 0 100 0001.   Sign bit is 0 positive⇒   Absolute value is 100 0001 = 65   Hence, the integer is +65

Example 2: Suppose that n=8 and the binary representation is 1 000 0001.   Sign bit is 1 negative⇒   Absolute value is 000 0001 = 1   Hence, the integer is -1

Page 27: Lesson 1   basic theory of information

Signed magnitude

Example 3: Suppose that n=8 and the binary representation is 0 000 0000.   Sign bit is 0 positive⇒   Absolute value is 000 0000 = 0   Hence, the integer is +0

Example 4: Suppose that n=8 and the binary representation is 1 000 0000.   Sign bit is 1 negative⇒   Absolute value is 000 0000B = 0   Hence, the integer is -0

Page 28: Lesson 1   basic theory of information
Page 29: Lesson 1   basic theory of information

Drawbacks

The drawbacks of sign-magnitude representation are: There are two representations (0000 0000B and

1000 0000B) for the number zero, which could lead to inefficiency and confusion.

Positive and negative integers need to be processed separately.

Page 30: Lesson 1   basic theory of information

One’s Complement

The most significant bit (msb) is the sign bit, with value of 0 representing positive integers and 1 representing negative integers.

The remaining n-1 bits represents the magnitude of the integer, as follows: for positive integers, the absolute value of the integer is

equal to "the magnitude of the (n-1)-bit binary pattern". for negative integers, the absolute value of the integer is

equal to "the magnitude of the complement (inverse) of the (n-1)-bit binary pattern" (hence called 1's complement).

Page 31: Lesson 1   basic theory of information

One’s complement

Example 1: Suppose that n=8 and the binary representation 0 100 0001.   Sign bit is 0 positive⇒   Absolute value is 100 0001 = 65   Hence, the integer is +65

Example 2: Suppose that n=8 and the binary representation 1 000 0001.   Sign bit is 1 negative⇒   Absolute value is the complement of 000 0001B, i.e., 111 1110B = 126   Hence, the integer is -126

Page 32: Lesson 1   basic theory of information
Page 33: Lesson 1   basic theory of information

Two’s complement

Again, the most significant bit (msb) is the sign bit, with value of 0 representing positive integers and 1 representing negative integers.

The remaining n-1 bits represents the magnitude of the integer, as follows: for positive integers, the absolute value of the integer is

equal to "the magnitude of the (n-1)-bit binary pattern". for negative integers, the absolute value of the integer

is equal to "the magnitude of the complement of the (n-1)-bit binary pattern plus one" (hence called 2's complement).

Page 34: Lesson 1   basic theory of information

Two’s complement

Example 1: Suppose that n=8 and the binary representation 0 000 0000.   Sign bit is 0 positive⇒   Absolute value is 000 0000 = 0   Hence, the integer is +0

Example 2: Suppose that n=8 and the binary representation 1 111 1111.   Sign bit is 1 negative⇒   Absolute value is the complement of 111 1111B plus 1, i.e., 000 0000 + 1 = 1   Hence, the integer is -1

Page 35: Lesson 1   basic theory of information
Page 36: Lesson 1   basic theory of information

Floating point representation

A real number is represented in exponential form (a = +- m x re)

1 bit 8 bits 23 bits (single precision)

0 10000100 11010000000000000000000

Sign Exponent Mantissa

Radix point

Page 37: Lesson 1   basic theory of information

IEEE Floating-Point Standard 754

Page 38: Lesson 1   basic theory of information

COMPLEMENTS

Complements are used in digital computers for simplifying the subtraction operation and for logical manipulations

2 types for each base-r system1) r’s complement (Radix complement)

2) (r-1)’s complement (Diminished radix Complement)

Page 39: Lesson 1   basic theory of information

Radix Complement

Referred to as r’s complement The r’s complement of N is obtained as (rn)-N

where

r = base or radix

n = number of digits

N = number

Page 40: Lesson 1   basic theory of information

Example Give the 10’s complement for the following number

a. 583978b. 5498

Solution:a. N = 583978 n = 6 106 - 583978

1,000,000 – 583978 = 436022b. N = 5498

n = 4 104 - 5498

10, 000 – 5498 = 4502

Page 41: Lesson 1   basic theory of information

Diminished Radix Complements

Referred to as the (r-1)s complement The (r-1)s complement of N is obtained as (rn-1)-

N where

r = base or radix

n = number of digits

N = number

Therefore 9’s complement of N is (10n-1)- N

Page 42: Lesson 1   basic theory of information

Example

Give the (r-1)’s complement for the following number if n=6

a. 567894

b. 012598

Page 43: Lesson 1   basic theory of information

Solution

Using the formula (rn-1)-N

if n = 6

r = 10

then 106 = 1, 000, 000 rn-1= 1, 000, 000 = 999, 999

Page 44: Lesson 1   basic theory of information

A.) N = 567894

999,999 – 567894 = 432105

Therefore, the 9’s complement of 567894 is 432105.

B.) N = 012598

999,999 – 012598 = 987401

Therefore, the 9’s complement of 012598 is 987401.

Page 45: Lesson 1   basic theory of information

Diminished Radix Complement

In the binary number system r=2 then r-1 = 1 so the 1’s complement of N is (2n-1)-N

When a binary digit is subtracted from 1, the only possibilities are 1-0=1 or 1-1=0

Therefore, 1’s complement of a binary numeral is formed by changing 1’s to 0’s and 0’s to 1’s.

Page 46: Lesson 1   basic theory of information

Example

Compute for the 1’s complement of each of the following binary numbers

a. 1001011

b. 010110101

Solution:

a. N=1001011

The 1’s complement of 1001011 is 0110100

b. N=010110101

The 1’s complement of 010110101 is 101001010

Page 47: Lesson 1   basic theory of information

Subtraction with Complements

The subtraction of two n-digit unsigned numbers M – N in base r can be done as follows: 1. Add the minuend M to the r’s complement of the

subtrahend N. If the M >= N, the sum will produce an end carry, rn,

which is discarded; what is left is the result M – N If M < N, the sum does not produce an end carry ans

is equal to rn – (N – M), which is the r’s complement of (N – M). To obtain the answer, take the r’s complement of the sum and place a negative sign in front.

Page 48: Lesson 1   basic theory of information

Using 10’s complement, subtract 72532 – 3250.

M = 72532

10’s complement of N = + 96750

Sum = 169282

Discard end carry 105 = - 100000

Answer = 69282

Page 49: Lesson 1   basic theory of information

Using 10’s complement, subtract 3250 – 72532.

M = 03250

10’s complement of N = + 27468

Sum = 30718

There is no end carry.

Answer = -69282

Get the 10’s complement of 30718.

Page 50: Lesson 1   basic theory of information

Using 9’s complement, subtract 89 – 23 and 98 – 87.

Page 51: Lesson 1   basic theory of information

Exercise

Given two binary numbers X = 1010100 and Y = 1000011, perform the subtraction (a) X – Y and (b) Y – X using 2’s complements and 1’s complement.

Page 52: Lesson 1   basic theory of information

Binary Codes

Decimal Digit (BCD)8421

Excess-3

0 0000 0011

1 0001 0100

2 0010 0101

3 0011 0110

4 0100 0111

5 0101 1000

6 0110 1001

7 0111 1010

8 1000 1011

9 1001 1100

In a digital system, it may sometimes represent a binary number, other times some other discrete quantity of information

Page 53: Lesson 1   basic theory of information

Non Numerical Representations

It refers to a representation of data other than numerical values. It refers to the representation of a character, sound or image.

Page 54: Lesson 1   basic theory of information

Standardizations of Character CodesCodename Description

EBCDIC Computer code defined by IBM for general purpose computers. 8 bits represent one character.

ASCII 7 bit code established by ANSI (American National Standards Institute). Used in PC’s.

ISO Code ISO646 published as a recommendation by the International Organization for Standardization (ISO), based on ASCII7 bit code for information exchange

Unicode An industry standard allowing computers to consistently represent characters used in most of the countries. Every character is represented with 2 bytes.

Page 55: Lesson 1   basic theory of information

Image and Sound Representations

Still Images GIF Format to save graphics, 256 colors displayable

JPEG Compression format for color still images

Moving Pictures Compression format for color moving pictures

MPEG-1 Data stored mainly on CD ROM

MPEG-2 Stored images like vide; real time images

MPEG-4 Standardization for mobile terminals

Sound PCM

MIDI Interface to connect a musical instrument with a computer.

Page 56: Lesson 1   basic theory of information

Operations and Accuracy

Shift operations It is the operation of shifting a bit string to the right

or left.

Arithmetic Shift Logical Shift

Left Arithmetic Left Shift Logical left shift

Right Arithmetic Right Shift Logical Right Shift

Page 57: Lesson 1   basic theory of information

Arithmetic Shift

Arithmetic Shift is an operation of shifting a bit string, except for the sign bit.

Example : Shift bits by 1

ALS

1 1 1 1 1 0 1 0

1 1 1 1 0 1 0 0

ARS

1 1 1 1 1 0 1 0

1 1 1 1 1 1 0 1Sign bit

Insert a zero in the vacated spot

Sign bit overflowoverflow

Page 58: Lesson 1   basic theory of information

Logical Shift It shifts a bit string and inserts “0” in places made

empty by the shift. Perform a logical left shift. Shift by 1 bit.

01111010 Perform a logical right shift. Shift by 1 bit.

10011001

Page 59: Lesson 1   basic theory of information

Exercise

Perform arithmetic right and logical right shifts by 3 bits on the 8th binary number 11001100.