Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Precision for locals?


From   wgould@stata.com (William Gould, StataCorp LP)
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Precision for locals?
Date   Wed, 12 Aug 2009 10:44:33 -0500

Sergiy Radyakin <serjradyakin@gmail.com> asked, 

> what is the precision with which the locals are stored in Stata?

and Maarten Buis <maartenbuis@yahoo.co.uk> replied, 

> A discussion of this can be found in (Gould, Pitblado, and
> Sribney 2003) page 83: "Macros provide about 12 digits of
> accuracy, sometimes more but never less. Scalars are full
> double-precision binary numbers, meaning they provide about
> 16.5 digits of accuracy in all cases"

The first sentence of what we wrote in 2003 should be updated to read, 

      Macros provide about 12 digits of accuracy, sometimes more, but 
      nevel less than 11.


As Kit Baum noted, often macros provide about the same as a double, 
for example, 

        . local x = sqrt(2)

        . display "`x'"
        1.414213562373095

Here is an example with 12 digits,

        . local x = sqrt(2)*10^20

        . display "`x'"
        1.41421356237e+20

Here is an example with 11 digits:

        . local x = sqrt(2)*10^102

        . display "`x'"
        1.4142135624e+102

-- Bill
wgould@stata.com
*
*   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/



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