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

Document magic numbers in Printf for Floats #41649

Closed
Seelengrab opened this issue Jul 20, 2021 · 2 comments · Fixed by #46020
Closed

Document magic numbers in Printf for Floats #41649

Seelengrab opened this issue Jul 20, 2021 · 2 comments · Fixed by #46020
Labels
domain:docs This change adds or pertains to documentation

Comments

@Seelengrab
Copy link
Contributor

For Ints and Chars (in the code above the one I link) it's somewhat more straightforward what the numbers mean and why they're chosen, but for Floats it's kind of guesswork unless you already know what they mean. This came up while investigating #41631

plength(f::Spec{T}, x::AbstractFloat) where {T <: Ints} =
max(f.width, 0 + 309 + 17 + f.hash + 5)
plength(f::Spec{T}, x) where {T <: Floats} =
max(f.width, f.precision + 309 + 17 + f.hash + 5)

@JeffBezanson JeffBezanson added the domain:docs This change adds or pertains to documentation label Jul 21, 2021
@Seelengrab
Copy link
Contributor Author

Seelengrab commented Aug 14, 2021

Just thought of looking at git blame for who to best ask about this, seems @quinnj may know? I'd be happy to make a PR once I'm sure I understand what each number means and/or where it comes from.

@quinnj
Copy link
Member

quinnj commented Aug 18, 2021

Hmmm, I'm not sure I quite remember where those exact numbers came from; roughly it's the total number of significant digits we're willing to print/allow for precision for floats.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:docs This change adds or pertains to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants