[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [COMMITTED] pkl, testsuite, doc: defunit, support for arbitrary name
From: |
Eric Blake |
Subject: |
Re: [COMMITTED] pkl, testsuite, doc: defunit, support for arbitrary named units |
Date: |
Sat, 29 Feb 2020 09:23:33 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 |
On 2/29/20 8:37 AM, Alfred M. Szmidt wrote:
I think following the lead of GNU Coreutils would be wise here
(https://www.gnu.org/software/coreutils/manual/html_node/Block-size.html):
I agree - any time we have different GNU programs with a different set
of ideas on what a suffix translates to, it breeds confusion.
defunit kB = 10 ** 3;
# `K' is special: the SI prefix is `k' and the ISO/IEC 80000-13 prefix
# is `Ki', but tradition and POSIX use `k' to mean `KiB'.
defunit k = 2 ** 10;
defunit K = 2 ** 10;
Hmm - this would work for bits.
defunit KiB = 2 ** 10;
But this, with an explicit B, is wrong (it is not 1024 bytes, but 1024
bits).
Do we want k to be kbits or kbytes?
defunit MB = 10 ** 6;
This name implies bytes, so it should be 8 * 10 ** 6. Do we also want
Mb for 1,000,000 bits?
defunit M = 2 ** 20;
This is ambiguous on whether it means bits or bytes. Per coreutils, if
we want it to mean mebibytes, we need 8 * 2 ** 20. (Yes, I avoid the
term mebibytes when I can, and usually say megabytes even when I mean
2**20 rather than 10**6, but in this context, my choice of wording is
intentional)
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
- [COMMITTED] pkl, testsuite, doc: defunit, support for arbitrary named units, Jose E. Marchesi, 2020/02/29
- Re: [COMMITTED] pkl, testsuite, doc: defunit, support for arbitrary named units, Alfred M. Szmidt, 2020/02/29
- Re: [COMMITTED] pkl, testsuite, doc: defunit, support for arbitrary named units,
Eric Blake <=
- Re: [COMMITTED] pkl, testsuite, doc: defunit, support for arbitrary named units, Jose E. Marchesi, 2020/02/29
- Re: [COMMITTED] pkl, testsuite, doc: defunit, support for arbitrary named units, Alfred M. Szmidt, 2020/02/29