Data Coding & Reference: Prepared by Sharmila Majumdar

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 13

Data Coding & Reference

Prepared by Sharmila Majumdar

Part of the process of programming is describing the attributes

of data that will be manipulated by a program. Thus, using Pascal, one may declare the fields and structures to be referenced in the procedural sections of a program: VAR a: interger VAR b, c, d: real VAR e, f, g: char VAR y: ARRAY OF char The variable a when used in the program will be an interger value. That is, it will never have a decimal portion. Variables b, c, and d, however, are real numbers that may have both interger and decimal parts. Variables e, f, and g are to be treated as strings of characters. The variable y is an array of character string variables.

Thus the string of bits 101001 represents the value 41 in the

decimal system in the following way: 2**5 2**4 2**3 2**2 2**1 2**0 (32) (16) (8) (4) (2) (1) 1 0 1 0 0 1 Vice versa Another way to represent Decimal digit Binary-coded representation 4 0100 5 0101 6 0110

Conversions Binary, Octal and Hexadecimal Pure Binary Number Representation


One of the attributes of a unit of memory is how many bits it

contains. We say, for example, that address 0001 of memory is 32 bits long when a string of 32 bits is referenced whenever address 0001 is used. Here we assume a machine that considers elements in its memory to be 32 bits long. We call this collection of 32 bits the word length of this system and assume that arithmetic will be dine on values of 32 bits in length. A method of representing algebraic values in a computer system is to treat a word as a single string of bits whose value is derived by application of the binary numbering system to the bits. In a 32-bit word the rightmost bit has a value of 2**0 and the leftmost bit has a value of 2**31: 00000000000000000000000001010101

The value 85 as a pure binary number in a 32-bit word is shown

in the preceding. If this word was at location in memory 500, we would say that the contents of location 500 was the value 85 in pure binary form. The preceding value is a positive value so that no convention is shown for the representation of a negative binary value. Various conventions are used to represent negative numbers in the pure binary numbering system. The possibilities are
-Use the high-order bit to represent sign. This is called signed magnitude.
In a system with a 32-bit word, the largest value that can be

represented is 31 bits long since 1 bit is used as a sign indicator. Thus 10000000000000000000000001010101 Represents the value -85 in pure binary.

Use the binary 1s complement of a number to represent its

negative value 11111111111111111111111110101010 In this form the negative of a number is developed by taking its 1s complement. The preceding is the 1s complement representation of -85. notice a negative number always has a 1 in the high-order bit of the word Use the binary 2s complement of number to represent its negative value: 11111111111111111111111110101011 In this form the negative of a number is developed by taking its 1s complement and adding a 1 to the value.

Addition

0110 0011 1001

6 3 9

Subtraction

1001 0110 0011

9 6 3

Sometimes an arithmetic operation will generate a value

that exceeds the number range of the architecture. The condition that arises from the generation of a number beyond the range of the architecture is called overflow. The condition obtains when two numbers of n digits create a sum of n+1 digits in a register of n-digit capacity. The condition can also occur with other arithmetic operations. For example, the binary addition of the value 70 and the value 80 will result in overflow in an 8-bit register using signed magnitude: 70 01000110 binary 80 01010000 binary 150 *0010110 the result of the addition is 150, but the capacity of the register is 127 (2**7 - 1)

Decimal Arithmetic
A basic encoding scheme is the representation of numbers in

0 1 2 3 4 5 6 7

decimal format. In this format a decimal number is represented as a string of bits where each group of four represents a particular binary digit. 0000 8 1000 0001 9 1001 0010 A 1010 001 1 B 101 1 0 100 C 1 100 0 10 1 D 1 1 01 0 1 10 E 1110 01 1 1 F 1111

A decimal value is represented as a string of 4-bit

groups. The sign of a decimal number is represented by a 4-bit group that either precedes or trails the actual number. The 4-bit form is sometimes called packed decimal to distinguish it from a form. To add decimal numbers, for example to add 128 to 344 128 0001 0010 1000 1111 344 0011 0100 0100 1111 472 0100 0111 0010 1111

To subtract the decimal value 344 from the decimal

value 472
472 344 128 0100 0111 0010 1111 0011 0100 0100 1111 0001 0010 1000 1111

A computer system have the ability to represent alphabetic

characters and a set of symbols that are either in common use (#, $, *, &, @, etc) that can be used as control signals in various parts of the system. The representation of nonnumeric data is accomplished in codes that may use 6, 7, or 8 bits to represent values. currently., almost all systems use either the 7-bit or the 8-bit code. The 6-bit codes provide for the representation of 64 unique symbols, the 7-bit codes provide for the representation of 128 unique symbols, and the 8-bit code allows 256 symbols to be represented. The 7-bit code represents a national standard called the ASCII(American standard code for information interchange. The 8-bit code is widely used by the IBM corporation, which is called EBCDIC (extended binary coded decimal interchange code).

An EBCDIC or ASCII character occupies exactly 1 byte of memory. Thus,

in a byte addressed system, the phrase AN APPLE would lay out as follows in EBCDIC: Memory Address Contents 0001 A(1100 0001) 0002 N(1101 0101) 0003 (0100 0000) 0004 A(1100 0001) 0005 P(1101 0111) 0006 P(1101 0111) 0007 L (1101 0011) 0008 E(1100 0101)

The code conventions are built into the arithmetic circuits, circuits that

print data, read data, show data on screens, send data to transmission lines, and so on.

You might also like