Skip to content

Commit

Permalink
Merge pull request #121 from jverzani/fix120
Browse files Browse the repository at this point in the history
fix #120
  • Loading branch information
jverzani committed Apr 25, 2017
2 parents 227b3ac + b8a2f33 commit afce991
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Polynomials.jl
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ julia> roots(poly([1,2,3,4]))
function roots{T}(p::Poly{T})
R = promote_type(T, Float64)
length(p) == 0 && return zeros(R, 0)
p = truncate(p)

num_leading_zeros = 0
while p[num_leading_zeros] zero(T)
if num_leading_zeros == length(p)-1
Expand Down
4 changes: 4 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ a_roots = copy(pN.a)
@test length(roots(p5)) == 4
@test roots(pNULL) == []
@test sort(roots(pR)) == [1//2, 3//2]
x = variable(Float64)
plarge = 8.362779449448982e41 - 2.510840694154672e57x + 4.2817430781178795e44x^2 - 1.6225927682921337e31x^3 + 1.0x^4 # #120
@test length(roots(plarge)) == 4


@test pNULL + 2 == p0 + 2 == 2 + p0 == Poly([2])
@test p2 - 2 == -2 + p2 == Poly([-1,1])
Expand Down

0 comments on commit afce991

Please sign in to comment.