Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Modify the Numeric version of infix:«<=>» to extend values with zeros…
…, so that (for Real $x) $x == $x + 0i.
  • Loading branch information
colomon committed Jun 20, 2010
1 parent 8e95548 commit ee7620d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/core/Numeric.pm
Expand Up @@ -257,7 +257,10 @@ multi sub infix:«cmp»(Numeric $a, Numeric $b) { $a <=> $b; }
multi sub infix:«<=>»(Numeric $a, Numeric $b) {
my @a = $a.reals;
my @b = $b.reals;
[||] (@a Z<=> @b), (+@a <=> +@b);
@a.push(0 xx +@b - +@a) if (+@a < +@b);
@b.push(0 xx +@a - +@b) if (+@b < +@a);

[||] (@a Z<=> @b);
}

multi sub infix==»(Numeric $a, Numeric $b) {
Expand Down

0 comments on commit ee7620d

Please sign in to comment.