Floating Point Rounding Errors
Quote:
Every base 10 integer can be exactly converted to a base 2 integer. All that the computer needs is enough bits. However, this is not true for fractional numbers. For example, the base 10 fraction 1/100 can be represented as the decimal number 0.01. However, when the same number is converted to binary, it becomes a repeating binary number. The reason that 1/100 cannot be represented exactly in base 2 is similar to the way that 1/3 cannot be represented exactly in base 10; only fractional base 10 numbers that can be represented in the form p/q, where q is an integer power of 2, can be expressed exactly with a finite number of ones (1) and zeros (0).
1. If I understand the quote: every number with a denominator with an integer power of 2 can be expressed without error in binary that is: x/1, x/2, x/4, x/8, x/16, etc can all be converted without error. All other fractions cannot be accurately converted to binary. Is this correct?
2. Is there a test that can be used to determine if a fraction can be accurately converted to decimal?