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

Option for human-readable format #335

Open
arkel-s opened this issue May 11, 2022 · 4 comments
Open

Option for human-readable format #335

arkel-s opened this issue May 11, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@arkel-s
Copy link

arkel-s commented May 11, 2022

First, thanks for this great tool!

For large code bases, the numerical output are hard to read, example:
image

It would be nice to get an option for human readable format, like 72.9 M (or 72.9e6)

@boyter boyter added the enhancement New feature or request label May 11, 2022
@boyter
Copy link
Owner

boyter commented May 11, 2022

That sounds useful. Do you know if there are any localisation problems with that @arkel-s ? Im not across what happens in Europe enough to determine that.

@arkel-s
Copy link
Author

arkel-s commented May 12, 2022

Oh yes, unfortunately there are many ways to write numbers, and no iso standard 😞
I believe that supporting this would be overkill, we can use either the UK/US way (123,456,798.01) ; scientific notation (1.23e6) or SI Prefixes, that have the advantage of being shorter.

Random copy/paste:

func LineCountDecimal(b int64) string {
        const unit = 1000
        if b < unit {
                return fmt.Sprintf("%d", b)
        }
        div, exp := int64(unit), 0
        for n := b / unit; n >= unit; n /= unit {
                div *= unit
                exp++
        }
        return fmt.Sprintf("%.1f %c", float64(b)/float64(div), "kMGTPE"[exp])
}

@nkh
Copy link

nkh commented Jul 9, 2023

Using an underscore also makes them more readable.

  1234567     987654321      458976213487    765321

1_234_567   987_654_321   458_976_213_487   765_321

@boyter
Copy link
Owner

boyter commented Jul 9, 2023

I might just make the decision to go with the US standard on this. Maybe with the option to modify it via a flag.

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

No branches or pull requests

3 participants