Just a note: Bits per seconds is usually counted in units of 1000, not 1024. Thus it should probably be 4.2 kbps.
/ Per Hedbor ()
Previous text:
2002-12-05 22:28: Subject: CHANGES line of the day
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.
/ Niels Möller ()