Decimals.jl
Decimals.jl copied to clipboard
Add a show method for pretty printing of Decimals
Currently there's not a Base.show method for the Decimal type. This makes them hard to read on the repl, in notebooks, and in DataFrames.
If people are attached to the verbose default show method this could be restricted to the text/html MIME type.
My suggestion here would be to have dec"1.0" string macro and use that for the default printing. Additionally, we can use :typeinfo to omit the wrapper in appropriate typed contexts.
Just to make things explicit, here's what this PR does:
julia> using Decimals
julia> # Current output
julia> Decimal(0.1)
Decimal(0, 1, -1)
julia> # New output with the code introduced in this PR
julia> Base.show(io::IO, d::Decimal) = print(io, string(d))
julia> Decimal(0.1)
0.1