We have learned and use the decimal numbering system simply because humans are born with ten fingers! Hence, the numeric system we is the decimal number system, but this system is not convenient for machines since the information is handled codified in the shape of ON or OFF bits.
Converting numbers from one radix (base) to another is a fundamental concept in computer science and mathematics. Here's an overview of the different methods for conversion:
1. Integer Conversion:
a) Decimal to Another Radix:
- Divide the number repeatedly by the target radix, noting the remainders from each division (in reverse order). These remainders become the digits in the new base.
- If the number is negative, convert the absolute value first, then add a negative sign at the end.
Example: Convert 235 (decimal) to binary.
- 235 / 2 = 117 R 1 -> 1 (least significant digit)
- 117 / 2 = 58 R 1 -> 1
- 58 / 2 = 29 R 0 -> 0
- 29 / 2 = 14 R 1 -> 1
- 14 / 2 = 7 R 0 -> 0
- 7 / 2 = 3 R 1 -> 1
- 3 / 2 = 1 R 1 -> 1
- 1 / 2 = 0 R 1 -> 1
Therefore, 235 (decimal) = 11101011 (binary).
b) Another Radix to Decimal:
- Multiply each digit by its corresponding place value (power of the original radix) and sum the results.
2. Fractional Conversion:
a) Decimal to Another Radix:
- Multiply the fractional part by the target radix repeatedly. Note the integer part of each product (these become digits in the new base).
- For the remaining fractional part, repeat step 1 until a repeating pattern emerges or a desired precision is reached.
Example: Convert 0.625 (decimal) to binary.
- 0.625 * 2 = 1.25 -> 1 (integer part)
- 0.25 * 2 = 0.5 -> 0 (integer part)
- 0.5 * 2 = 1.0 -> 1 (integer part)
Therefore, 0.625 (decimal) = 0.101 (binary) (repeating pattern).
b) Another Radix to Decimal:
- Sum the values of each digit multiplied by its corresponding place value (a fraction of the original radix).
Example: Convert 234.14 expressed in an octal notation to decimal.
0comments:
Post a Comment
Note: only a member of this blog may post a comment.