Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix comparison ops for Complex numbers
  • Loading branch information
moritz committed Nov 26, 2011
1 parent 4a4601d commit 2154ebb
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/core/Complex.pm
Expand Up @@ -21,7 +21,7 @@ my class Complex is Numeric {
self.re.isNaN || self.im.isNaN;
}

method Real(Complex:D:) {
multi method Real(Complex:D:) {
if $!im == 0 {
$!re;
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/core/Cool.pm
Expand Up @@ -175,7 +175,7 @@ my class Cool {
eval(self.Stringy, |%opts);
}

method Real() { self.Numeric.Real }
multi method Real() { self.Numeric.Real }
method Int() { self.Numeric.Int }
method Num() { self.Numeric.Num }
method Rat() { self.Numeric.Rat }
Expand Down
5 changes: 5 additions & 0 deletions src/core/Mu.pm
Expand Up @@ -126,6 +126,11 @@ my class Mu {
note 'Use of uninitialized value in numeric context';
0
}
proto method Real(|$) { * }
multi method Real(Mu:U:) {
note 'Use of uninitialized value in numeric context';
0
}

proto method Str(|$) { * }
multi method Str(Mu:U:) {
Expand Down
10 changes: 5 additions & 5 deletions src/core/Numeric.pm
Expand Up @@ -213,7 +213,7 @@ multi infix:<**>(\$a, \$b) { $a.Numeric ** $b.Numeric }
## relational operators

proto infix:«<=>»(|$) { * }
multi infix:«<=>»(\$a, \$b) { $a.Numeric <=> $b.Numeric }
multi infix:«<=>»(\$a, \$b) { $a.Real <=> $b.Real }

proto infix:<==>($a?, $b?) { * }
multi infix:<==>($x?) { Bool::True }
Expand All @@ -225,19 +225,19 @@ multi infix:<!=>(\$a, \$b) { $a.Numeric != $b.Numeric }

proto infix:«<»($a?, $b?) { * }
multi infix<»($x?) { Bool::True }
multi infix<»(\$a, \$b) { $a.Numeric < $b.Numeric }
multi infix<»(\$a, \$b) { $a.Real < $b.Real }

proto infix:«<=»($a?, $b?) { * }
multi infix<=»($x?) { Bool::True }
multi infix<=»(\$a, \$b) { $a.Numeric <= $b.Numeric }
multi infix<=»(\$a, \$b) { $a.Real <= $b.Real }

proto infix:«>»($a?, $b?) { * }
multi infix>»($x?) { Bool::True }
multi infix>»(\$a, \$b) { $a.Numeric > $b.Numeric }
multi infix>»(\$a, \$b) { $a.Real > $b.Real }

proto infix:«>=»($a?, $b?) { * }
multi infix>=»($x?) { Bool::True }
multi infix>=»(\$a, \$b) { $a.Numeric >= $b.Numeric }
multi infix>=»(\$a, \$b) { $a.Real >= $b.Real }

## bitwise operators

Expand Down

0 comments on commit 2154ebb

Please sign in to comment.