Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make Rat.Num return +/- Inf if the denominator is 0.
  • Loading branch information
colomon committed Feb 24, 2010
1 parent a7874a7 commit 4f74e3b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/core/Rat.pm
Expand Up @@ -27,7 +27,10 @@ class Rat {

our Bool multi method Bool() { $!numerator != 0 ?? Bool::True !! Bool::False }

multi method Num() { $!numerator.Num / $!denominator.Num; }
multi method Num() {
$!denominator == 0 ?? Inf * $!numerator.sign
!! $!numerator.Num / $!denominator.Num;
}

multi method Rat() { self; }

Expand Down

0 comments on commit 4f74e3b

Please sign in to comment.