Skip to content

Commit

Permalink
Add method roots() to Numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
leto committed Mar 21, 2009
1 parent fb7d44d commit e5ae093
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/builtins/any-num.pir
Expand Up @@ -184,6 +184,15 @@ error.

=cut

.sub 'roots' :method :multi(I)
.param num n
.local pmc x
.local pmc result
x = self
result = 'roots'(x,n)
.return (result)
.end

.sub 'unpolar' :method
.param num angle
.local num mag
Expand Down
4 changes: 3 additions & 1 deletion src/builtins/math.pir
Expand Up @@ -36,7 +36,9 @@ Returns the $N roots of a Complex number $z.
# $P5[1] = 1

if n > 0 goto positive
.return ('NaN')
roots = 1
roots[0] = 'NaN'
goto done
positive:
if n > 1 goto general
roots[0] = x
Expand Down

0 comments on commit e5ae093

Please sign in to comment.