Decimals.jl icon indicating copy to clipboard operation
Decimals.jl copied to clipboard

Add a show method for pretty printing of Decimals

Open amellnik opened this issue 7 years ago • 3 comments

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.

amellnik avatar Oct 09 '18 22:10 amellnik

If people are attached to the verbose default show method this could be restricted to the text/html MIME type.

amellnik avatar Oct 09 '18 22:10 amellnik

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.

Keno avatar Apr 20 '19 23:04 Keno

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

waldyrious avatar Jun 18 '20 18:06 waldyrious