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

Adaptive number of significant digits #179

Open
sharkdp opened this issue Sep 26, 2023 · 4 comments
Open

Adaptive number of significant digits #179

sharkdp opened this issue Sep 26, 2023 · 4 comments
Labels

Comments

@sharkdp
Copy link
Owner

sharkdp commented Sep 26, 2023

or at least: support for high-precision integer computations

for more details, see previous discussion here: sharkdp/insect#54

@sharkdp sharkdp changed the title Adaptive number of significant digits or at least: support for high-precision integer computations Adaptive number of significant digits Sep 26, 2023
@archisman-panigrahi
Copy link
Contributor

Given how the code is written right now, is it nontrivial to change the behavior to the following?

Calculate and store variables with high precision (as far as machine precision allows) but show only 6 significant digits

@sharkdp
Copy link
Owner Author

sharkdp commented Sep 27, 2023

Calculate and store variables with high precision (as far as machine precision allows) but show only 6 significant digits

This is what we do already.

@philippotto
Copy link

Another example to motivate this issue: I just did my taxes (yay) and used numbat for some simple additions. This simplified output caught me a bit off-guard:

  10000 euro + 0.95 euro

    = 10001 €    [Money]

Especially, when dealing with currencies, it seems intuitive to me to render two digits after the dot (unless it's 0). However, I often omit the units if the calculation only involves a single unit type. Therefore, special casing currencies wouldn't have helped me much. Instead, I would love to see some logic à la "render the result with the same precision that was used in the input".

My suggestion probably over-simplifies things, but maybe it's still somehow helpful.

@septatrix
Copy link

I wanted to calculate the downtime of some services and was confused that nine nines (99.9999999% uptime) was showed as 100%:

>>> 1year * (1-99.9999999%) -> ms

  1 year × (1 - 100 percent) ➞ millisecond

      = 31.5569 ms    [Time]

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

No branches or pull requests

4 participants