Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Problem with power operator


From   Matthias Greiner <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   st: Problem with power operator
Date   Wed, 28 Aug 2002 14:55:07 +0200

Dear Stata users

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. 

Thanks in advance for your help.
Matthias 
---
Matthias Greiner, Dr. med. vet.
Head of the International EpiLab
Danish Veterinary Institute
B�lowsvej 27, DK-1790 Copenhagen V
Tel +45 35 30 01 40
Fax +45 35 30 06 16
[email protected]
www.vetinst.dk/EpiLab 
*
*   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