[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v10 2/9] include: Add a lookup table of sizes

From: Alberto Garcia
Subject: Re: [Qemu-devel] [PATCH v10 2/9] include: Add a lookup table of sizes
Date: Mon, 24 Sep 2018 15:58:23 +0200
User-agent: Notmuch/0.18.2 (http://notmuchmail.org) Emacs/24.4.1 (i586-pc-linux-gnu)

On Fri 21 Sep 2018 07:23:03 PM CEST, Leonid Bloch wrote:
> Adding a lookup table for the powers of two, with the appropriate size
> prefixes. This is needed when a size has to be stringified, in which
> case something like '(1 * KiB)' would become a literal '(1 * (1L << 10))'
> string. Powers of two are used very often for sizes, so such a table
> will also make it easier and more intuitive to write them.
> This table is generatred using the following AWK script:
>       suffix="KMGTPE";
>       for(i=10; i<64; i++) {
>               val=2**i;
>               s=substr(suffix, int(i/10), 1);
>               n=2**(i%10);
>               pad=21-int(log(n)/log(10));
>               printf("#define S_%d%siB %*d\n", n, s, pad, val);
>       }
> }
> Signed-off-by: Leonid Bloch <address@hidden>

Reviewed-by: Alberto Garcia <address@hidden>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]