develooper Front page | perl.perl6.users | Postings from June 2019

Odd Complex behavior

Thread Next
From:
Sean McAfee
Date:
June 13, 2019 17:39
Subject:
Odd Complex behavior
Message ID:
CANan03bpt3DuNROEodxsR7Pr38HZ9OR9wO-cBT=jL+=CAjpHeQ@mail.gmail.com
> 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?

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About