MCPcopy Create free account
hub / github.com/F-Stack/f-stack / xo_humanize

Function xo_humanize

tools/libxo/libxo/libxo.c:3710–3729  ·  view source on GitHub ↗

* A wrapper for humanize_number that autoscales, since the * HN_AUTOSCALE flag scales as needed based on the size of * the output buffer, not the size of the value. I also * wish HN_DECIMAL was more imperative, without the <10 * test. But the boat only goes where we want when we hold * the rudder, so xo_humanize fixes part of the problem. */

Source from the content-addressed store, hash-verified

3708 * the rudder, so xo_humanize fixes part of the problem.
3709 */
3710static ssize_t
3711xo_humanize (char *buf, ssize_t len, uint64_t value, int flags)
3712{
3713 int scale = 0;
3714
3715 if (value) {
3716 uint64_t left = value;
3717
3718 if (flags & HN_DIVISOR_1000) {
3719 for ( ; left; scale++)
3720 left /= 1000;
3721 } else {
3722 for ( ; left; scale++)
3723 left /= 1024;
3724 }
3725 scale -= 1;
3726 }
3727
3728 return xo_humanize_number(buf, len, value, "", scale, flags);
3729}
3730
3731/*
3732 * This is an area where we can save information from the handle for

Callers 1

xo_format_humanizeFunction · 0.85

Calls 1

xo_humanize_numberFunction · 0.85

Tested by

no test coverage detected