Post Reply 
negative number raised to even power
05-07-2015, 06:41 PM
Post: #71
RE: negative number raised to even power
(05-07-2015 06:29 PM)PANAMATIK Wrote:  
(05-07-2015 05:50 PM)Dave Britten Wrote:  Then I disagree with "standard mathematical notation". If -2^2=-4, then as far as I'm concened, 2.5^2=2.25 is just as valid.

I strongly agree with Dave.

-2 is a number preceded by the unary minus operator

and

0-2 is a subtraction.

In "the C programming language" 1977 by Kernighan/Ritchie/ Prentice Hall, Inc. the unary minus is already defined (operators, page 54 in the german edition) and has higher priority than multiplication/division and thus also higher than exponentiation, (but as exponentiation is not an operator but a function call in C this is inherent).

See also wikipedia "Operators", which differentiates also between unary minus and subtraction operator.

Imagine you store the number -2 in register 0 of an RPN calculator or in a variable y in C, then

Code:

RCL 0
2
y/x
is 4

or
Code:

result= pow(y,2);  // result is 4

Bernhard

Personally, I wouldn't even consider the negation symbol to be a unary operator, but rather a fundamental component of the number. In other words, I don't consider it an operator any more than I would the decimal point. Thus if it's not an operator, order of operations is irrelevant, and the number should be fully parsed before carrying out any operations on it.

Keep in mind I'm a CS guy, so I'm just speaking to what makes the most intuitive sense based on my knowledge of parsers and grammars and such. One could probably make perfectly rational arguments to the opposite as well, I just don't like them. Smile
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
negative number raised to even power - DrD - 04-25-2015, 11:24 AM
RE: negative number raised to even power - Dave Britten - 05-07-2015 06:41 PM



User(s) browsing this thread: 2 Guest(s)