octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 3.0.2 release (mingw32 check)


From: John W. Eaton
Subject: Re: 3.0.2 release (mingw32 check)
Date: Tue, 26 Aug 2008 14:21:13 -0400

On 26-Aug-2008, Benjamin Lindner wrote:

| Now out of curiosity:
| Why is the expression "-i" not immediatly created as std::complex with a 
| imaginary part of -1 and a default real part of 0?

Because there is no special case for unary minus in the parser.  It is
still an expression that must be evaluated.

If we change that, then you would see different results for

  -i  ->  0 - 1i

and

  a = i; -a;  ->  -0 - 1i

Is that really what you want?

| Seems as "-i" is b
| imterpreted as "(-1)*i" whereas "-1/3" is a single expression. Right?

I'm not sure what you mean by "single expression".  They are both
expressions that must be evaluated.  The expression -i is parsed as

  unary-minus imaginary-constant

and the expression -1/3 is parsed as

 unary-minus constant / constant

with the unary-minus having higher precedence than the division
operation.  In lisp notation, these would be

 (- I)
 (/ (- 1.0) 3.0)

(assuming I is the complex constant with real part 0 and imaginary
part 1).

jwe


reply via email to

[Prev in Thread] Current Thread [Next in Thread]