Skip to content

Commit 8c9abbf

Browse files
authored
Issue 372a (#374)
* adjust rational conversion in N(a,digits)
1 parent 4a7e7d8 commit 8c9abbf

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "SymPy"
22
uuid = "24249f21-da20-56a4-8eb1-6a02cf4ae2e6"
3-
version = "1.0.29"
3+
version = "1.0.30"
44

55

66
[deps]

src/numbers.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,10 +283,14 @@ function N(x::Sym, digits::Int; kwargs...)
283283
if is_integer(x)
284284
return(convert(BigInt, x))
285285
elseif is_rational(x)
286-
return N(numer(x), digits;kwargs...) / N(denom(x), digits; kwargs...)
286+
p = round(Int, log2(10)*digits)
287+
ex = x.evalf(1+digits)
288+
out = setprecision(p) do
289+
convert(BigFloat, ex)
290+
end
291+
return(out)
287292
elseif is_real(x) == true
288293
p = round(Int, log2(10)*digits)
289-
290294
out = setprecision(p) do
291295
convert(BigFloat, ex)
292296
end

0 commit comments

Comments
 (0)