Subject: | Inconsistent behaviour in ** |
There is an inconsistency in the overloaded "**" operator. Even
when both operands are Math::Complex, the output is not always a
Math::Complex object. I consider the inconsistency a bug.
use strict;
use warnings;
use Math::Complex;
for my $exp (-2 .. 2) {
my $x = Math::Complex -> new(2);
my $y = Math::Complex -> new($exp);
my $z = $x ** $y;
print "$x ** $y = $z as a ", ref($z) || "scalar", "\n";
}
gives
2 ** -2 = 0.25 as a Math::Complex
2 ** -1 = 0.5 as a Math::Complex
2 ** 0 = 1 as a scalar <=== huh?
2 ** 1 = 2 as a Math::Complex
2 ** 2 = 4 as a Math::Complex