Skip to content

Commit

Permalink
Issue 372a (#374)
Browse files Browse the repository at this point in the history
* adjust rational conversion in N(a,digits)
  • Loading branch information
jverzani committed Sep 22, 2020
1 parent 4a7e7d8 commit 8c9abbf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "SymPy"
uuid = "24249f21-da20-56a4-8eb1-6a02cf4ae2e6"
version = "1.0.29"
version = "1.0.30"


[deps]
Expand Down
8 changes: 6 additions & 2 deletions src/numbers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,14 @@ function N(x::Sym, digits::Int; kwargs...)
if is_integer(x)
return(convert(BigInt, x))
elseif is_rational(x)
return N(numer(x), digits;kwargs...) / N(denom(x), digits; kwargs...)
p = round(Int, log2(10)*digits)
ex = x.evalf(1+digits)
out = setprecision(p) do
convert(BigFloat, ex)
end
return(out)
elseif is_real(x) == true
p = round(Int, log2(10)*digits)

out = setprecision(p) do
convert(BigFloat, ex)
end
Expand Down

2 comments on commit 8c9abbf

@jverzani
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/21798

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.0.30 -m "<description of version>" 8c9abbf3cff5884445cd9887a629c7b9d6be5477
git push origin v1.0.30

Please sign in to comment.