Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Precision


From   Sergio Correia <sergio.correia@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Precision
Date   Fri, 11 Nov 2005 11:20:00 -0500

Thanks.

By the way, when I did the -browse-, I noticed that even if the data
is correctly displayed in the "spreadsheet", it isn't so in the box
located in the upper side of the screen (under the HIDE button). In
the second case, I only see 348080.2688552. Kinda funny as the box
usually shows full precision even if the numbers are formatted as
%2.0f in the spreadsheet.

Sergio


On 11/11/05, Michael Blasnik <michael.blasnik@verizon.net> wrote:
> You have forgotten to format the values properly, so you think you lost
> precision when you didn't.  All of the digits in your example are maintained
> when you use doubles or destring.  Try your code, but then :
>
> di %20.10f c
>    348080.2688552010
>
> Michael Blasnik
> michael.blasnik@verizon.net
>
> ----- Original Message -----
> From: "Sergio Correia" <sergio.correia@gmail.com>
> <snip>
> > However, as the following example can show, this is not enough to
> > maintain ALL the precision.
> >
> > 1) make the data
> > input str20 x
> > 348080.2688552010
> > end
> >
> > 2)
> > gen a=real(x)
> > gen double b=real(x)
> > destring x, gen(c)
> > browse
> >
> > 3) Alternative (a) is pretty bad.
> > (b) and (c) give 3.4808026885520e+05, which is pretty close.
> >
> > If that is not enough, I can't help.
> <snip>
>
> *
> *   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/
>

*
*   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/



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