COMPUTER EDUCATION (E-504) UNIT III: BINARY ARITHMETIC AND DATA REPRESENTATIONS

NUMBER SYSTEMS: The number system is a way to represent or express numbers. You have heard of various types of number systems such as the whole numbers and the real numbers. But in the context of computers, we define other types of number systems. They are:

Number Systems

The Decimal Number The Binary Number The Octal Number The System System System And Number System

DECIMAL NUMBER SYSTEM (Base 10)

In this number system, the digits 0 to 9 represents numbers. As it uses 10 digits to represent a number, it is also called the base 10 number system. Each digit has a value based on its position called place value. The value of the position increases by 10 times as we move from right to left in the number.

For example, the value of 786 is

= 7 x 102 + 8 x 101 + 6 x 100

= 700 + 80 + 6

BINARY NUMBER SYSTEM (Base 2) A computer can understand only the “on” and “off” state of a switch. These two states are represented by 1 and 0. The combination of 1 and 0 form binary numbers. These numbers represent various data. As two digits are used to represent numbers, it is called a binary or base 2 number system.

The binary number system uses positional notation. But in this case, each digit is multiplied by the appropriate power of two based on its position.

For example, (101101)2 in decimal is

= 1 x 25 + 0 x 24 + 1 x 23 + 1 x 22 + 0 x 21 + 1 x 20

= 1 x 32 + 0 x 16 + 1 x 8 + 1 x 4 + 0 x 2 + 1 x 1

= 32 + 8 + 4 + 1

= (45)10

OCTAL NUMBER SYSTEM (Base 8)

This system uses digits 0 to 7 (i.e. 8 digits) to represent a number and the numbers are as a base of 8.

For example, (24)8 in decimal is

= 2×81+4×80

= (20)10

HEXADECIMAL NUMBER SYSTEM (Base 16)

In this system, 16 digits used to represent a given number. Thus it is also known as the base 16 number system. Each digit position represents a power of 16. As the base is greater than 10, the number system is supplemented by letters. Following are the hexadecimal symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F

To take A, B, C, D, E, and F as part of the number system is conventional and has no logical or deductive reason.

CONVERSION OF NUMBER SYSTEM FROM ONE NUMBER SYSTEM TO ANOTHER NUMBER SYSTEM

DECIMAL TO BINARY

Decimal numbers can be converted to binary by repeated division of the number by 2 while recording the remainder. Let’s take an example to see how this happens.

The remainders are to be read from bottom to top to obtain the binary equivalent.

4310 = 1010112

BINARY TO DECIMAL

n The decimal number is equal to the sum of binary digits (dn) times their power of 2 (2 ):

DECIMAL TO OCTAL

Decimal numbers can be converted to octal by repeated division of the number by 8 while recording the remainder. Let’s take an example to see how this happens.

Reading the remainders from bottom to top, 47310 = 7318

DECIMAL TO HEXADECIMAL

Decimal numbers can be converted to octal by repeated division of the number by 16 while recording the remainder. Let’s take an example to see how this happens.

Reading the remainders from bottom to top we get, 42310 = 1A716

REPRESENTATION OF CHARACTERS. Computers work in binary. As a result, all characters, whether they are letters, punctuation or digits, are stored as binary numbers. All of the characters that a computer can use are called a character set. Digital Computers use Binary number system to represent all types of information inside the computers. Binary number system is suitable for this purpose due to following reasons: • Electronic components in digital computers operate in binary mode. A switch is either on (1) or off (0); a transistor is either conducting (1) or non-conducting(0). • Computers have to handle only two digits (bits) rather than 10. So binary system simplifies design, reduce the cost and improve the reliability of the computer. • Everything that can be done with decimal system can also be done using a binary system. Character Codes-Representation of alphanumeric characters in bits 0 and 1 is done by character codes. There are three widely used character codes: • Binary Coded Decimal(BCD) • American standard Code for Information Interchange (ASCII) • Extended Binary Coded Decimal Interchange Code(EBCDIC) Binary Coded Decimal (BCD) BCD uses 6 bits and can represent 26 =64 characters. The first three bits are used as zone bits and the last three bits indicate the digit.

American Standard Code for Information Interchange (ASCII) Code ASCII-7: uses 7 bits and can represent 27 =128 characters. The first three bits are used as zone bits and the last four bits indicate the digit. Hexadecimal numbers are used as shortcut notation for memory dump.

ASCII-8: uses 8 bits and can represent 28 =256 characters. For all practical purposes an 8-bit code is used.8th bit is added for parity. Characters are assigned decimal values.

Extended Binary Coded Decimal Interchange Code (EBCDIC) It is an 8 bit code. It can represent 28 =256 characters. It is two groups of 4 digits. Each group represents a hexadecimal number, used as shortcut notation for binary numbers.

INTEGERS AND FRACTIONS IN COMPUTERS. Integer representation The binary numbers used in digital computers must be represented by using binary storage devices such as Flip-Flops (FF). Each device represent one bit. The most direct number system representation for binary valued storage devices is an integer representation system. Simply writing the value or states of the flip-flops gives the number in integer form. For example, a 6-bit FF register could store binary numbers ranging from 000000 to 111111 (0 to 63 in decimal). Since digital computers handle +ve as well as –ve numbers, some means is required for representing the sign of the number (+ or -). This is usually done by placing another bit called sign bit to the left of the magnitude bits. 0 in sign bit position represent a +ve number while a 1 in sign bit position represent a –ve number. a. Unsigned Integer Simply writing the values of the FF gives the magnitude of the number in the Unsigned Integer form. b. Signed Integer 0 in the leftmost bit represents positive and 1 in the sign bit represents negative. +27

Sign magnitude numbers are used only when we do not add or subtract the data. They are used in analog to digital conversions. They have limited use as they require complicated arithmetic circuits.

FIXED POINT REPRESENTATION AND FLOATING POINT REPRESENTATION.

A real number or floating point number has integer part and fractional part separated by a decimal. It is either positive or negative. e.g. 0.345, -121.37 etc.

Fixed Point Representation: One method of representing real numbers would be to assume a fixed position for the decimal point. e.g. in a 8-bit fixed point representation, where 1 bit is used for sign (+ve or –ve) and 5 bits are used for integral part and two bits are used for fractional part:

Represents binary number +11100.11

Largest positive number which can be stored 11111.11

Smallest positive number which can be stored 00000.01

This range is quite inadequate even for simple arithmetic calculations. To increase the range we use floating point representation.

Floating Point Representation: In floating point representation, the number is represented as a combination of a mantissa, m, and an exponent e.

In such a representation it is possible to float a decimal point within number towards left or right side.

For example: