Adds ability to write suffixed values instead of number of bytes
Details
Diff Detail
Event Timeline
You can use SI prefixes (i.e. K/M/G/T/etc.) with other units than M, so combining the two and call it FormattedMemory doesn't sound like a good idea. In addition to that, SI prefixes are not correct as they represents powers of 10 instead of powers of 2.
How about adding FormattedBinaryPrefix class which prints out Ki/Mi/Gi/... for 2^10/2^20/2^30/.... ? For Ki/Mi/Gi, see https://en.wikipedia.org/wiki/Binary_prefix.
I appreciate the differences, but this is specifically to output an amount of memory in a human readable form.
Using KiB, MiB, etc may be pedantically correct, but it limits the usefulness of this to format text for a user who may have little knowledge of the differences between SI and IEC suffixes.
Every operating system I'm aware of does it this way and having output correlate to how the OS reports memory is more important.
@ruiu
What about an optional argument to specific IEC suffixes.
Using IEC by default is fine by me, just that there is a way to not do so.
I agree the name is probably too general, but format_binary_prefix is a bit obtuse.
What about format_memory_size instead?