Matthias  Greiner
> Using 
> 
> . do "... \square.do"
> 
> . program define square
>   1. version 7.0
>   2. gettoken n 0 : 0, parse(" ,")
>   3. local nsquared1=`n'^2
>   4. local nsquared2=(`n'*`n')
>   5. di "`nsquared1'   `nsquared2'"
>   6. end
> . 
> end of do-file
> 
> I observe the following misbehaviour of the power operator "^2"
> 
> . square -2
> -4   4
> 
> The example is for illustration -- the problem occurs in a 
> real programme,
> where the negative value n is a result of internal (and correct)
> calculations. I am puzzled because I never observed this before. 
> 
Nick Winter and Hakon Finne have already identified
the problem clearly. 
There is a fuller exposition at 
I coded 'a'2 and got the wrong sign. Why?
http://www.stata.com/support/faqs/lang/macpow.html
Nick 
[email protected] 
*
*   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/