**Chapter – Data representation**

**Number System**

Number of digits used in a number system is called its base or radix. We can categorize number system as below:

**Binary number system****Octal Number System****Decimal Number System****Hexadecimal Number system**Conversion between number systems can be done easily.

Representation of Decimal numbers

We can normally represent decimal numbers in one of following two ways

**By converting into binary****By using BCD codes****By converting into binary**

**Advantage**

Arithmetic and logical calculation becomes easy. Negative numbers can be represented easily.

Disadvantage

At the time of input conversion from decimal to binary is needed and at the time of output conversion from binary to decimal is needed.Therefore this approach is useful in the systems where there is much calculation than input/output.

**By using BCD codes**

**Disadvantage**

Arithmetic and logical calculation becomes difficult to do. Representation of negative numbers is tricky.

Advantage

At the time of input conversion from decimal to binary and at the time of output conversion from binary to decimal is not needed. Therefore this approach is useful in the systems where there is much input/output than arithmetic and logical calculation.

**Â Complements**

**(R-1)’s Complement**

(R-1)’s complement of a number N is defined as (r^n-1)-N

Where N is the given number r is the base of number systemÂ ,n is the number of digits in the given number

To get the (R-1)’s complement fast, subtract each digit of a number from (R-1)

Example

- Â 9’s complement of 83510 is 16410
- 1’s complement of 10102 is 01012(bit by bit complement operation)

**R’s Complement**

R’s complement of a number N is defined as r^n-NÂ Where N is the given number

r is the base of number system ,n is the number of digits in the given number

To get the R’s complement fast, add 1 to the low-order digit of its (R-1)’s complement

- Â 10’s complement of 83510 is 16410 + 1 = 16510
- 2’s complement of 10102 is 01012 + 1 = 01102