[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: Decimal precision, again
Sylvain Friederich <S.Friederich@bristol.ac.uk> asks about getting back
-double- precision when the data was read using only float:
> [...] I made a mistake in -insheet-ing some data (or, ahem, just because
> the "double" option of -insheet- didn't work well until recently) and I
> think a particular variable appearing as a float in my data should really be
> there with double precision.
> Re-processing this data from scratch would represent a tremendous drag.
> Would outsheeting the Stata dataset and re-insheeting it using the "double"
> option fix this unambiguously?
Many people have already responded on the list that one cannot get back was
has been lost. As Michael Blasnik <email@example.com> put it, "When
a variable is stored as a float, the precision beyond float is lost."
Right they are, unless ... unless you know something about how the original
number should look. For instance, pretend I have decimal numbers with
one digit to the right of the decimal place such as
If I store these numbers as float, I end up with
Knowing that there is just one digit to the right of the decimal, however,
I can promote back to double:
. gen double fixed = round(old*10,1)/10
The answer is that one cannot get back the original precision unless, in the
reduced precision number, there is enough information so that one can know
what the rest of the numbers would have been. That always requires the
addition of outside information, but you may have that.
As another example, if someone writes down 3.1415927, I would bet the original
number is even closer to 3.141592653589793.
* For searches and help try: