logo

utils

~/.local/bin tools and git-hooks git clone https://hacktivis.me/git/utils.git
commit: 2f3ed56aa3d126aad4cf69987c50759333549224
parent 87274b96510774cf6a6ae3737f57bea4f1d7114b
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Sat, 19 Nov 2022 21:29:07 +0100

cmd/humanize: Add new 2022 prefixes

Technically useless since it cannot go beyond exabytes.

Diffstat:

Mcmd/humanize.c8+++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/cmd/humanize.c b/cmd/humanize.c @@ -18,15 +18,17 @@ void dtosi(double num, char *buf, size_t bufsize, bool iec) { - char *si_prefixes[9] = {"", "k", "M", "G", "T", "P", "E", "Z", "Y"}; - char *iec_prefixes[9] = {"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"}; +#define PFX 11 + char *si_prefixes[PFX] = {"", "k", "M", "G", "T", "P", "E", "Z", "Y", "R", "Q"}; + char *iec_prefixes[PFX] = { + "B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB", "RiB", "QiB"}; int div = iec ? 1024 : 1000; char **prefixes = iec ? iec_prefixes : si_prefixes; unsigned quotient = 0; - while(num > div && quotient < 9) + while(num > div && quotient < PFX) { num /= div; quotient += 1;