Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a show method for pretty printing of Decimals #24

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

amellnik
Copy link

@amellnik amellnik commented Oct 9, 2018

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
Copy link
Author

amellnik commented Oct 9, 2018

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

@Keno
Copy link
Contributor

Keno commented Apr 20, 2019

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.

@waldyrious
Copy link

waldyrious commented Jun 18, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants