Skip to content

Commit

Permalink
Rough but working versions of Int.sign and Rat.sign.
Browse files Browse the repository at this point in the history
Actually, these pass the spectest but the Rat.sign one is definitely returning the wrong thing.  Will try to correct both spectest and code shortly.
  • Loading branch information
colomon committed Nov 23, 2009
1 parent 6bf0179 commit 1445ba3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/setting/Int.pm
Expand Up @@ -32,6 +32,10 @@ class Int is also {
our Complex multi method unpolar($angle) is export {
Complex.new(self.Num * $angle.cos("radians"), self.Num * $angle.sin("radians"));
}

our Int multi method sign() {
self.Num.sign.Int
}
}

multi sub abs(Int $x) { $x.abs }
Expand Down
4 changes: 4 additions & 0 deletions src/setting/Rat.pm
Expand Up @@ -48,6 +48,10 @@ class Rat {
multi method abs {
self < 0 ?? -self !! self;
}

our Rat multi method sign() {
self.Num.sign.Rat
}
}

multi sub infix:<+>(Rat $a, Rat $b) {
Expand Down

0 comments on commit 1445ba3

Please sign in to comment.