Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
separate FatRat.perl, fix Rational.Str
  • Loading branch information
moritz committed Feb 13, 2012
1 parent ddd1f02 commit 5b9e9af
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/core/Rat.pm
Expand Up @@ -40,12 +40,9 @@ my role Rational is Real {
method Int() { $!numerator div $!denominator }

method Bridge() { self.Num }
multi method Str(Rat:D:) {
multi method Str(Rational:D:) {
self.Num.Str
}
multi method perl(Rat:D:) {
$!numerator ~ '/' ~ $!denominator
}
method succ {
Rat.new($!numerator + $!denominator, $!denominator);
}
Expand All @@ -59,6 +56,9 @@ my role Rational is Real {
my class Rat does Rational {
method Rat (Rat:D: Real $?) { self }
method FatRat(Rat:D: Real $?) { FatRat.new($.numerator, $.denominator); }
multi method perl(Rat:D:) {
$.numerator ~ '/' ~ $.denominator
}
}
my class FatRat does Rational {
method FatRat(FatRat:D: Real $?) { self }
Expand All @@ -67,6 +67,9 @@ my class FatRat does Rational {
?? Rat.new($.numerator, $.denominator)
!! fail "Cannot convert from FatRat to Rat because denominator is too big";
}
multi method perl(FatRat:D:) {
"FatRat.new($.numerator, $.denominator)";
}
}

sub DIVIDE_NUMBERS(Int:D \$nu, Int:D \$de, $t1, $t2) {
Expand Down

0 comments on commit 5b9e9af

Please sign in to comment.