[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
wgould@stata.com (William Gould, Stata) |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Decimal precision, again |

Date |
Fri, 25 Jul 2003 12:58:55 -0500 |

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 <michael.blasnik@verizon.net> 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 100.1 42.4 103894.3 If I store these numbers as float, I end up with 100.0999984741211 42.40000152587891 103894.296875 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. -- Bill wgould@stata.com * * For searches and help try: * http://www.stata.com/support/faqs/res/findit.html * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**Re: st: Decimal precision, again***From:*"SJ Friederich, Economics" <S.Friederich@bristol.ac.uk>

- Prev by Date:
**st: Re: Re: Re: Re: marginal effects** - Next by Date:
**Re: st: Decimal precision, again** - Previous by thread:
**st: "outreg" for d-stats, comparison of means tests, etc.** - Next by thread:
**Re: st: Decimal precision, again** - Index(es):

© Copyright 1996–2016 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |