In the last episode (Dec 05), Niels Mller () @ Pike (-) developers forum said:
After writing some code similar to int2size, I'll suggest that it either skips the unit, and/or takes an additional argument that is the unit. E.g.
int2size(4200, "bps") ==> 4.1 Kbps
Perhaps one should have one function that produces 2^10 prefixes, and another one that produces standard SI (or whatever the stanrd is) prefixes. The latter function could take floats rather than ints, though. Like
foo(0.01, "s") => 10 ms
Or perhaps that gets a little too complicated, e.g. one would also want to provide the precision. Perhaps something for sprintf.
I think you've found the reason everyone writes their own. By the time you come up with a function that satisfies everyone, it'll have 6 arguments and no-one will bother to use it because it's too complicated :)