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 digits keyword argument to format_bytes #55495

Closed
wants to merge 2 commits into from

Conversation

KristofferC
Copy link
Member

No description provided.

base/timing.jl Outdated
Comment on lines 158 to 159
julia> Base.format_bytes(10000; sigdigits=1)
"9.8 KiB"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I missing something or these are two significant digits? Compare with round:

julia> round(10000 / 1024; sigdigits=1)
10.0

julia> round(10000 / 1024; sigdigits=2)
9.8

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, the docs for Ryu.writefixed says:

precision: minimum number of significant digits to be included in the decimal string; extra '0'
characters will be added for padding if necessary

So it is the number of sig digits of the decimals I guess.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what round calls "digits":

julia> round(10000 / 1024; digits=0)
10.0

julia> round(10000 / 1024; digits=1)
9.8

julia> round(10000 / 1024; digits=3)
9.766

@KristofferC KristofferC changed the title add sigdigits keyword argument to format_bytes add digits keyword argument to format_bytes Aug 15, 2024
@giordano giordano deleted the kc/sigdigits_timing branch October 10, 2024 12:20
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.

2 participants