[GH-ISSUE #391] kib, mib, etc for -o should be powers of 1024, not 1000 #174

Closed
opened 2026-06-08 11:25:59 +03:00 by zhus · 6 comments
Owner

Originally created by @eatsu on GitHub (Apr 26, 2024).
Original GitHub issue: https://github.com/bootandy/dust/issues/391

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!

Originally created by @eatsu on GitHub (Apr 26, 2024). Original GitHub issue: https://github.com/bootandy/dust/issues/391 According to [Wikipedia](https://en.wikipedia.org/wiki/Byte#Multiple-byte_units), KiB, MiB, etc are units based on [binary prefixes](https://en.wikipedia.org/wiki/Binary_prefixes) which are powers of 1024, but in Dust they seem to be treated as [SI units](https://en.wikipedia.org/wiki/SI_prefix) 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!
zhus closed this issue 2026-06-08 11:25:59 +03:00
Author
Owner

@bootandy commented on GitHub (Apr 27, 2024):

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.

<!-- gh-comment-id:2081143665 --> @bootandy commented on GitHub (Apr 27, 2024): 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.
Author
Owner

@bootandy commented on GitHub (Apr 27, 2024):

https://github.com/bootandy/dust/pull/392

does this look right ?

<!-- gh-comment-id:2081161282 --> @bootandy commented on GitHub (Apr 27, 2024): https://github.com/bootandy/dust/pull/392 does this look right ?
Author
Owner

@eatsu commented on GitHub (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.

<!-- gh-comment-id:2081272956 --> @eatsu commented on GitHub (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`.
Author
Owner

@bootandy commented on GitHub (Apr 28, 2024):

Noted, updated.

<!-- gh-comment-id:2081427596 --> @bootandy commented on GitHub (Apr 28, 2024): Noted, updated.
Author
Owner

@eatsu commented on GitHub (Apr 29, 2024):

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

<!-- gh-comment-id:2081790749 --> @eatsu commented on GitHub (Apr 29, 2024): Ah, it now works perfectly for me. Thank you again!
Author
Owner

@bootandy commented on GitHub (May 1, 2024):

will go out in next release

<!-- gh-comment-id:2088997975 --> @bootandy commented on GitHub (May 1, 2024): will go out in next release
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: bootandy/archived-dust#174