
Dear Reinhard Meyer,
In message 4D3FECB2.1010007@emk-elektronik.de you wrote:
Will the preffered methods be xx << 10 for KiB xx << 20 for MiB xx << 30 for GiB and so on?
Please note that the binary prefixes kibi and mebi not might be used for other things than bytes as well. And if we were trying to be precise, wie might want to use "octets" instead of bytes anyway ;-)
I think it's largely a matter of taste and experience whether you prefer (2 << 30) or (2 * 1024 * 1024 * 1024). It depends a lot on how much you work with such numbers - I prefer (2 << 30) because it's shorter, others find the "* 1024" notation easier to read.
But no matter what you prefer - at least both variants are readable.
Or might we have a few macros like
#define KiB(x) ((x) << 10) #define MiB(x) ((x) << 20) and so on?
Why should we use any such macros at all? Just write the plain numbers in the code so everybody can understand it without having to look up the definition.
Best regards,
Wolfgang Denk