Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
smarter FatRat numification
  • Loading branch information
moritz committed Feb 13, 2012
1 parent bd5adba commit 91c3326
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions src/core/Rat.pm
Expand Up @@ -35,7 +35,10 @@ my role Rational is Real {
method Num() {
$!denominator == 0
?? ($!numerator < 0 ?? -$Inf !! $Inf)
!! $!numerator.Num / $!denominator.Num
!! nqp::p6box_n(nqp::div_In(
nqp::p6decont($!numerator),
nqp::p6decont($!denominator)
));
}
method Int() { $!numerator div $!denominator }

Expand Down Expand Up @@ -91,10 +94,9 @@ sub DIVIDE_NUMBERS(Int:D \$nu, Int:D \$de, $t1, $t2) {
nqp::bindattr($r, Rat, '$!denominator', nqp::p6decont($denominator));
$r;
} else {
# TODO: be smarter here if both integers are big
nqp::p6box_n(nqp::div_n(
nqp::tonum_I(nqp::p6decont $numerator),
nqp::tonum_I(nqp::p6decont $denominator)
nqp::p6box_n(nqp::div_In(
nqp::p6decont($numerator),
nqp::p6decont($denominator)
)
);
}
Expand Down
2 changes: 1 addition & 1 deletion tools/build/NQP_REVISION
@@ -1 +1 @@
2012.01-9-gfd864b6
2012.01-10-g7f521e3

0 comments on commit 91c3326

Please sign in to comment.