diff options
| author | Melodi <62381002+Melodi17@users.noreply.github.com> | 2026-03-17 20:49:22 +1000 |
|---|---|---|
| committer | Melodi <62381002+Melodi17@users.noreply.github.com> | 2026-03-17 20:49:22 +1000 |
| commit | 18868128e18d38b706e7df14e8e683e1a9739c17 (patch) | |
| tree | 6f0e0e5eee646f10cbad9c0c89c24d330bc58cc6 /RegionVisualiser/SizeFormatter.cs | |
| parent | d87ab8af4c86a3fc6ee237444e372d87e536e3ef (diff) | |
chore: Initial commit
Diffstat (limited to 'RegionVisualiser/SizeFormatter.cs')
| -rw-r--r-- | RegionVisualiser/SizeFormatter.cs | 25 |
1 files changed, 0 insertions, 25 deletions
diff --git a/RegionVisualiser/SizeFormatter.cs b/RegionVisualiser/SizeFormatter.cs deleted file mode 100644 index 3479bd8..0000000 --- a/RegionVisualiser/SizeFormatter.cs +++ /dev/null @@ -1,25 +0,0 @@ -namespace RegionVisualiser; - -public static class SizeFormatter -{ - private static readonly string[] Units = ["bytes", "KB", "MB", "GB", "TB"]; - - public static string HumanReadable(long bytes) - { - if (bytes < 1024) return $"{bytes} {SizeFormatter.Units[0]}"; - - double value = bytes; - int unit = 0; - - while (value >= 1024 && unit < SizeFormatter.Units.Length - 1) - { - value /= 1024; - unit++; - } - - // Show up to 2 decimal places if not whole - return value % 1 == 0 - ? $"{value:0} {SizeFormatter.Units[unit]}" - : $"{value:0.##} {SizeFormatter.Units[unit]}"; - } -}
\ No newline at end of file |
