Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

# Re: st: precision problem using double

 From Stas Kolenikov To statalist@hsphsun2.harvard.edu Subject Re: st: precision problem using double Date Sun, 16 Oct 2011 14:29:09 -0500

```On top of NJC's response (which is on the spot, of course, as always),
another useful function is -reldif- along with -epsfloat-/-espdouble-
(which gives the relative accuracy, unlike the -smallestdouble- that
gives a number that is way too small to be relevant):

sysuse auto
sum gear_ratio
list if gear_ratio == 3.89
list if reldif(gear_ratio, 3.89) < 10*c(epsfloat)

This comes handy in comparisons with fixed known constants. Of course,
in your case, you should use -r(max)- which is a scalar with double
precision (2e-16) rather than -`r(max)'- which is a string; if the
latter is in scientific notation, it may have accuracy lower than
1e-15.

On Sat, Oct 15, 2011 at 1:37 AM, Leandro Brufman
<leandrobrufman@gmail.com> wrote:
> Been reading some stuff on the precision of double, and how Stata
> http://www.stata-journal.com/sjpdf.html?articlenum=dm0022)
> But couldn't find a solution. Here's my problem:
>
>
> * it returns that there are no observations.
>
>
> *it also returns that there are no observations
>
>
> * the minimum number of variable test is -2.84217094e-14
>
> any ideas on how to fix this code? i don't need a lot of precision,
> but I do need to have these two lines working fine:
>
>
> as usual, many many thanks in advance...
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>

--
Stas Kolenikov, also found at http://stas.kolenikov.name
Small print: I use this email account for mailing lists only.

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```