Statalist The Stata Listserver


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

Re: Re: st: RE: ml and variable types: Scalar vs. Local precision?


From   n j cox <[email protected]>
To   [email protected]
Subject   Re: Re: st: RE: ml and variable types: Scalar vs. Local precision?
Date   Thu, 21 Dec 2006 14:47:35 +0000

That's an interesting example. At this moment no manuals
are ready to hand for me to quote them at you.

But in principle your example doesn't involve the
use of locals _for_ arithmetic. You asked Stata to
evaluate its version of pi and store a string
representation in a local and that's not much
of a strain, even if there are several decimal places
that can be shown. You can see a difference with

. local pi = _pi

. local foo = 10^(20*`pi')

. scalar foo = 10^(20*_pi)

. di %30.27g `foo'
     6.789738869139999900e+62

. di %30.27g scalar(foo)
     6.789738869143769600e+62

and naturally you see more differences if you
start subtracting, calculating derivatives, etc.

Nick
[email protected]

Austin Nichols

Nick--
I know this was once true, and used to be the source of much
frustration in -while- loops, but is it still the case?

local pi=_pi
scalar pi=_pi
di %32.20f `pi'
di %32.20f pi
di %32.20f float(pi)

suggests not.

On 12/20/06, Nick Cox <[email protected]> wrote:

The answer is Yes, and this is prominently documented.

Although it is unlikely to be the source of the problem,
it will do no harm to cast anything you care about as
a scalar not a local.

Nick
[email protected]

Rachel

> Another issue is that some constants inside the
> evaluator are defined as scalars and others as locals.  Do locals
> (when evaluated with single quotes) have a lower precision than
> scalars?
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index