Skip to content

Commit

Permalink
Merge pull request #75 from isuruf/lambdify
Browse files Browse the repository at this point in the history
convert sign(BigInt) to a Int
  • Loading branch information
isuruf authored Mar 13, 2017
2 parents e98c949 + ffb39b6 commit 7886714
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/numerics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,10 @@ function N(b::BasicType{Val{:Integer}})
return 0
else
u = unsafe_load(a.d, 1)
if u <= typemax(Int64)
return Int64(u) * sign(a)
elseif sign(a) == 1
w = signed(u)
if w > 0
return w * a.size
elseif a.size == 1
return u
else
return a
Expand Down
4 changes: 4 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,8 @@ z,flt, rat, ima, cplx = btypes = [Basic(1), Basic(1.23), Basic(3//5), Basic(2im)
t = BigFloat(1.23)
@test !SymEngine.have_component("mpfr") || t == convert(BigFloat, convert(Basic, t))

@test typeof(N(Basic(-1))) != BigInt

# Check that libversion works. VersionNumber should always be >= 0.2.0
# since 0.2.0 is the first public release
@test SymEngine.libversion >= VersionNumber("0.2.0")

0 comments on commit 7886714

Please sign in to comment.