> (-i).reals
(-0 -1)
> Complex.new(0, -1).reals
(0 -1)
> ((-1)i).reals
(0 -1)
This is precisely what I would expect to happen.
There is a postfix `i` operator for things like `1i`, but there is
also a constant `i`
# from src/core/Complex.pm6
constant i = Complex.new(0e0, 1e0);
When you do `-i` you are negating both the `0e0` and the `1e0`.
> (-Complex.new(0, 1)).reals
(-0 -1)
Note that you can't just do `-1i` either, because postfix operators
`i` happen before prefix operators `-`.
So you need to do `(-1)i` or `0-1i`.
On Thu, Jun 13, 2019 at 12:39 PM Sean McAfee <[email protected]> wrote:
>
> > bag i, 2i - i
> bag(0+1i(2))
>
> Well and good.
>
> > bag -i, -2i + i
> bag(0-1i, -0-1i)
>
> Huh? But this works as expected:
>
> > bag Complex.new(0, -1), Complex.new(0, -2) + Complex.new(0, 1)
> bag(0-1i(2))
>
> Is this a bug, or is there a sense in which it's correct?
>