Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: Why the square of a negative number is still negative
From
Richard Williams <[email protected]>
To
[email protected]
Subject
Re: st: Why the square of a negative number is still negative
Date
Fri, 16 Dec 2011 11:47:34 -0500
See http://www.stata.com/support/faqs/lang/macpow.html. If you are
not careful, what you intend to be seen as a negative sign is instead
being interpreted as a minus sign.
At 11:31 AM 12/16/2011, Tiago V. Pereira wrote:
Dear statalisters,
Can someone explain why is this happening?:
local x = -2
*/Approach A:
dis (`x'^2)*(5)
*/Approach B:
dis (`x'*`x')*(5)
*/Approach C:
dis ((`x')^2)*(5)
My output is:
. dis (`x'^2)*(5)
-20
. */Approach B:
. dis (`x'*`x')*(5)
20
. */Approach C:
. dis ((`x')^2)*(5)
20
Do I need vacations? (Am I forgetting something very simple from
mathematics?)
All the best,
Tiago
*
* 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/
-------------------------------------------
Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
HOME: (574)289-5227
EMAIL: [email protected]
WWW: http://www.nd.edu/~rwilliam
*
* 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/