Skip to content

Commit

Permalink
fix Num.Rat
Browse files Browse the repository at this point in the history
  • Loading branch information
moritz committed Jul 2, 2011
1 parent a425e09 commit 2c0fd1c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/core/Num.pm
Expand Up @@ -16,13 +16,14 @@ my class Num {
method Rat(Real $epsilon = 1.0e-6) {
my sub modf($num) { my $q = $num.Int; $num - $q, $q; }

my $num = self;
my $signum = $num < 0 ?? -1 !! 1;
my Num $num = self;
my Int $signum = $num < 0 ?? -1 !! 1;
$num = -$num if $signum == -1;

# Find convergents of the continued fraction.

my ($r, $q) = modf($num);
my Num $r = $num - $num.Int;
my Int $q = $num.Int;
my ($a, $b) = 1, $q;
my ($c, $d) = 0, 1;

Expand Down

0 comments on commit 2c0fd1c

Please sign in to comment.