From 8c9abbf3cff5884445cd9887a629c7b9d6be5477 Mon Sep 17 00:00:00 2001 From: john verzani Date: Tue, 22 Sep 2020 14:13:15 -0400 Subject: [PATCH] Issue 372a (#374) * adjust rational conversion in N(a,digits) --- Project.toml | 2 +- src/numbers.jl | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Project.toml b/Project.toml index b832ef33..91350754 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "SymPy" uuid = "24249f21-da20-56a4-8eb1-6a02cf4ae2e6" -version = "1.0.29" +version = "1.0.30" [deps] diff --git a/src/numbers.jl b/src/numbers.jl index 5b3ce534..6db79c56 100644 --- a/src/numbers.jl +++ b/src/numbers.jl @@ -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