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

kib, mib, etc for -o should be powers of 1024, not 1000 #391

Closed
eatsu opened this issue Apr 26, 2024 · 6 comments
Closed

kib, mib, etc for -o should be powers of 1024, not 1000 #391

eatsu opened this issue Apr 26, 2024 · 6 comments

Comments

@eatsu
Copy link
Contributor

eatsu commented Apr 26, 2024

According to Wikipedia, KiB, MiB, etc are units based on binary prefixes which are powers of 1024, but in Dust they seem to be treated as SI units which are powers of 1000.

https://github.com/bootandy/dust/blob/v1.0.0/src/display.rs#L412-L420

I'm afraid this is technically incorrect and is confusing.

For reference, commands du, df and ls treat K, M, KiB, MiB, etc as powers of 1024 and KB, MB, etc as powers of 1000. Quoting from their --help:

The SIZE argument is an integer and optional unit (example: 10K is 10*1024).
Units are K,M,G,T,P,E,Z,Y,R,Q (powers of 1024) or KB,MB,... (powers of 1000).
Binary prefixes can be used, too: KiB=K, MiB=M, and so on.

I would appreciate it if this were fixed and k, m, etc could be used as aliases for kib, mib, etc, like the above commands convention.

Thanks!

@bootandy
Copy link
Owner

Oh wow that's embarrassing. I've implemented it backwards, haven't I. Good find. How did you notice that ?

I think this is a recent bug only in this version, it's from when I merged the behaviour of the now redundant --si flag.

@bootandy
Copy link
Owner

#392

does this look right ?

@eatsu
Copy link
Contributor Author

eatsu commented Apr 28, 2024

How did you notice that ?

I noticed that the values of the output K was different between with -o kib and without the flag when working on _dust_output_formats in #390 :)

does this look right ?

kib / mib / kb / mb work now as I expected as far as I've tested. Thank you! However, it seems that k / m are now powers of 1000, which is different from the behavior of du / df / ls.

@bootandy
Copy link
Owner

Noted, updated.

@eatsu
Copy link
Contributor Author

eatsu commented Apr 29, 2024

Ah, it now works perfectly for me. Thank you again!

@bootandy
Copy link
Owner

bootandy commented May 1, 2024

will go out in next release

@bootandy bootandy closed this as completed May 1, 2024
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

No branches or pull requests

2 participants