|
Indeed. You're expecting a simple answer when none exists. Floating point variables, contrary to what people seem to expect, cannot not hold just any old real value. They hold a set of discrete values.
If I was to say you can only represent your data to three significant figures, and then give you data of 83.39 (which has 4 significant figures) you would drop one figure, and probably store it as either 83.3 or 83.4 (depending on whether you choose to round up or down). Once you've done that, there would then be no way you can get back to the actual value of 83.39. Floating point variables work the same way: the only difference is that they work in binary (base 2) rather than base 10 (decimal) so the set of values where the effect is obvious are different. One phenomenon is that 0.1 (1/10th decimal) and 0.01 (1/100th decimal) cannot be represented exactly in base 2, so some decimal values cannot be represented in floating point values. Changing to base 10 would not fix the problem -- it would only change the set of values where the effect becomes visible: try to represent the fraction 1/3 with only a finite number of decimal places, and you will encounter exactly the same problem.
Without knowing why you are getting your knickers in a twist over this, it is not possible to give a workable solution. If your data can be (in theory) any real data, then you will have to live with the imprecision of floating point or do your calculations by hand. I gave an option above, if the reason you want to represent 83.39 exactly is because you are working with currency (eg if the notion of a fraction of a cent is meaningless).
|