Decimals.jl
Decimals.jl copied to clipboard
rounding failures
round(Int, Decimal(3.5))
and round(Decimal(3.5), RoundNearest)
are both failing at floatfuncs.jl:136.
It looks like most similar types have customer implementations of least the latter and usually the former.
Traces:
julia> round(Int, Decimal(3.5))
ERROR: MethodError: no method matching round(::Decimal, ::RoundingMode{:Nearest})
Closest candidates are:
round(::Real, ::RoundingMode; digits, sigdigits, base) at floatfuncs.jl:129
round(::Float64, ::RoundingMode{:Nearest}) at float.jl:376
round(::Float32, ::RoundingMode{:Nearest}) at float.jl:377
...
Stacktrace:
[1] #round#566 at ./floatfuncs.jl:134 [inlined]
[2] round at ./floatfuncs.jl:129 [inlined]
[3] round(::Type{Int64}, ::Decimal) at ./float.jl:367
[4] top-level scope at REPL[19]:1
[5] eval(::Module, ::Any) at ./boot.jl:331
[6] eval_user_input(::Any, ::REPL.REPLBackend) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:86
[7] run_backend(::REPL.REPLBackend) at /home/sean/.julia/packages/Revise/C272c/src/Revise.jl:1075
[8] top-level scope at none:0
julia> round(Decimal(3.5), RoundNearest)
ERROR: MethodError: no method matching round(::Decimal, ::RoundingMode{:Nearest})
Closest candidates are:
round(::Real, ::RoundingMode; digits, sigdigits, base) at floatfuncs.jl:129
round(::Float64, ::RoundingMode{:Nearest}) at float.jl:376
round(::Float32, ::RoundingMode{:Nearest}) at float.jl:377
...
Stacktrace:
[1] #round#566 at ./floatfuncs.jl:134 [inlined]
[2] round(::Decimal, ::RoundingMode{:Nearest}) at ./floatfuncs.jl:129
[3] top-level scope at REPL[23]:1
[4] eval(::Module, ::Any) at ./boot.jl:331
[5] eval_user_input(::Any, ::REPL.REPLBackend) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:86
[6] run_backend(::REPL.REPLBackend) at /home/sean/.julia/packages/Revise/C272c/src/Revise.jl:1075
[7] top-level scope at none:0