diff --git a/src/DecFP.jl b/src/DecFP.jl index 41ec941..4698377 100644 --- a/src/DecFP.jl +++ b/src/DecFP.jl @@ -807,6 +807,8 @@ promote_rule(::Type{Irrational{s}}, T::Type{Complex{F}}) where {s,F<:DecimalFloa Base.widen(::Type{Dec32}) = Dec64 Base.widen(::Type{Dec64}) = Dec128 +Printf.tofloat(x::DecimalFloatingPoint) = BigFloat(x) + macro d_str(s, flags...) parse(Dec64, s) end macro d32_str(s, flags...) parse(Dec32, s) end macro d64_str(s, flags...) parse(Dec64, s) end diff --git a/test/runtests.jl b/test/runtests.jl index bab4a02..e81e1b2 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -184,6 +184,9 @@ for T in (Dec32, Dec64, Dec128) @test @sprintf("%.2f %.4f", T("12.34567"), 9.87) == "12.35 9.8700" + # issue #178 + @test @sprintf("%.36f", T("0.1")) == "0.100000000000000000000000000000000000" + x,y,z = 1.5, -3.25, 0.0625 # exactly represented in binary xd = T(x); yd = T(y); zd = T(z)