1665 words - 7 pages

Binary Decimal Octal and Hexadecimal number systems

A number can be represented with different base values. We are familiar with the numbers in the base 10 (known as decimal numbers), with digits taking values 0,1,2,…,8,9. A computer uses a Binary number system which has a base 2 and digits can have only TWO values: 0 and 1. A decimal number with a few digits can be expressed in binary form using a large number of digits. Thus the number 65 can be expressed in binary form as 1000001. The binary form can be expressed more compactly by grouping 3 binary digits together to form an octal number. An octal number with base 8 makes use of the EIGHT digits 0,1,2,3,4,5,6 and 7. A more compact ...view middle of the document...

Then we print the remainders in reverse order. Example: convert (68)10 to binary 68/2 = 34 remainder is 0 34/ 2 = 17 remainder is 0 17 / 2 = 8 remainder is 1 8 / 2 = 4 remainder is 0 4 / 2 = 2 remainder is 0 2 / 2 = 1 remainder is 0 1 / 2 = 0 remainder is 1 We stop here as the number has been reduced to zero and collect the remainders in reverse order. Answer = 1 0 0 0 1 0 0 Note: the answer is read from bottom (MSB, most significant bit) to top (LSB least significant bit) as (1000100)2 . You should be able to write a recursive function to convert a binary integer into its decimal equivalent.

Conversion of binary fraction to decimal fraction

In a binary fraction, the position of each digit(bit) indicates its relative weight as was the case with the integer part, except the weights to in the reverse direction. Thus after the decimal point, the first digit (bit) has a weight of ½ , the next one has a weight of ¼ , followed by 1/8 and so on.

20

.

2-1 . 1

2-2 0

2-3 1

2-4 1

… 0

.... 0

…

0

The decimal equivalent of this binary number 0.1011 can be worked out by considering the weight of each bit. Thus in this case it turns out to be (1/2) x 1 + (1/4) x 0 + (1/8) x 1 + (1/16) x 1.

Conversion of decimal fraction to binary fraction

To convert a decimal fraction to its binary fraction, multiplication by 2 is carried out repetitively and the integer part of the result is saved and placed after the decimal point. The fractional part is taken and multiplied by 2. The process can be stopped any time after the desired accuracy has been achieved. Example: convert ( 0.68)10 to binary fraction. 0.68 * 2 = 1.36 integer part is 1 Take the fractional part and continue the process 0.36 * 2 = 0.72 integer part is 0 0.72 * 2 = 1.44 integer part is 1 0.44 * 2 = 0.88 integer part is 0 The digits are placed in the order in which they are generated, and not in the reverse order. Let us say we need the accuracy up to 4 decimal places. Here is the result. Answer = 0. 1 0 1 0….. Example: convert ( 70.68)10 to binary equivalent. First convert 70 into its binary form which is 1000110. Then convert 0.68 into binary form upto 4 decimal places to get 0.1010. Now put the two parts together. Answer = 1 0 0 0 1 1 0 . 1 0 1 0….

Octal Number System

•Base or radix 8 number system. •1 octal digit is equivalent to 3 bits. •Octal numbers are 0 to7. (see the chart down below) •Numbers are expressed as powers of 8. See this table

8n-1

8n-2

…… …… 83

82 6

81 3

80 2

Conversion of octal to decimal ( base 8 to base 10)

Example: convert (632)8 to decimal = (6 x 82) + (3 x 81) + (2 x 80) = (6 x 64) + (3 x 8) + (2 x 1) = 384 + 24 + 2 = (410)10

Conversion of decimal to octal ( base 10 to base 8)

Example: convert (177)10 to octal equivalent 177 / 8 = 22 remainder is 1 22 / 8 = 2 remainder is 6 2 / 8 = 0 remainder is 2 Answer = 2 6 1 Note: the answer is read from bottom to top as (261)8, the same as with the binary case.

...

Find the perfect research document on any subject