diff options
author | Denys Séguret <cano.petrole@gmail.com> | 2024-07-31 13:55:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-31 13:55:59 +0100 |
commit | 56104947e459d52c3ae8d1c45e9378922e4d11d6 (patch) | |
tree | fd64cdeaaceac5aef3486a24b3d4f700b5c02d15 | |
parent | a76edb2778334eb2843455816fc9474792a41ce3 (diff) | |
parent | 4a087a2af7bdd0bc6410537a53ac2e47aad97b2c (diff) |
Merge pull request #79 from NoisyCoil/base-2-logs
Use base-2 logs to retrieve binary prefixes
-rw-r--r-- | cli/src/units.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/cli/src/units.rs b/cli/src/units.rs index cb77a39..faa4ea9 100644 --- a/cli/src/units.rs +++ b/cli/src/units.rs @@ -37,9 +37,9 @@ impl Units { if size < 10_000 { size.to_string() } else { - let size = size as f64; - let i: u32 = (size.ln() / 1024f64.ln()) as u32; + let i = size.ilog2() / 10u32; let idx = i as usize - 1; + let size = size as f64; if idx >= PREFIXES.len() { "huge".to_string() } else { |