Skip to content

Commit

Permalink
Rat updates, add another spectest.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmichaud committed Jul 6, 2011
1 parent c4ca652 commit 25b3ee6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/core/Rat.pm
Expand Up @@ -3,8 +3,8 @@ my class Rat is Real {
has $.numerator;
has $.denominator;

method new(Rat:U: Int \$nu, Int \$de) {
my $new = self.CREATE;
method new(Int \$nu = 0, Int \$de = 1) {
my $new := self.CREATE;
my $gcd = $nu gcd $de;
my $numerator = $nu div $gcd;
my $denominator = $de div $gcd;
Expand All @@ -22,8 +22,11 @@ my class Rat is Real {

method nude() { $!numerator, $!denominator }
method Num() {
$!numerator.Num / $!denominator.Num
$!denominator == 0
?? ($!numerator < 0 ?? -$Inf !! $Inf)
!! $!numerator.Num / $!denominator.Num
}
method Int() { self.Num.Int }

method Bridge() { self.Num }
method Rat() { self }
Expand Down
2 changes: 1 addition & 1 deletion t/spectest.data
Expand Up @@ -525,7 +525,7 @@ S32-num/log.t
S32-num/polar.t
# S32-num/power.t
# S32-num/rand.t
# S32-num/rat.t
S32-num/rat.t
# S32-num/real-bridge.t
# S32-num/roots.t
# S32-num/rounders.t
Expand Down

0 comments on commit 25b3ee6

Please sign in to comment.