Statalist


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

Re: st: Precision for locals?


From   [email protected] (William Gould, StataCorp LP)
To   [email protected]
Subject   Re: st: Precision for locals?
Date   Wed, 12 Aug 2009 10:44:33 -0500

Sergiy Radyakin <[email protected]> asked, 

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

and Maarten Buis <[email protected]> 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
[email protected]
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index