[Toybox] [PATCH] Add support for 1024 as well as 1000 to human_readable.
Rob Landley
rob at landley.net
Mon Aug 24 18:47:03 PDT 2015
On 08/24/2015 03:10 PM, enh wrote:
> On Sun, Aug 23, 2015 at 6:20 PM, Rob Landley <rob at landley.net> wrote:
>> /me wists for a specification. Oh well. I hate when I have to guess at
>> what the right behavior _is_...
>
> yeah, i was actually trying to avoid ending up with all the heuristics
> the BSD implementation has.
>
> the BSD man page says:
>
> If the formatted number (including suffix) would be too long to fit into
> buf, then divide number by 1024 until it will.
That's just "test against 999, divide by 1024". Easy enough.
> The len argument must be at least 4 plus the length of suffix, in order
> to ensure a useful result is generated into buf.
That constraint's already implicit. I should make sure it's explicit.
> so it certainly seems they follow the "no more than three digits/two
> digits plus '.'" rule.
I can work with this.
Thanks,
Rob
1440467223.0
More information about the Toybox
mailing list