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 ()
Previous text:
2002-12-05 21:34: Subject: CHANGES line of the day
Man kan också lägga till under String
Examples:
String.int2char(42);
(1) Result: "*"
String.int2hex(42);
(2) Result: "2a"
String.int2roman(42);
(3) Result: "XLII"
String.int2size(4200);
(4) Result: "4.1 kb"
/ Martin Nilsson (hehe Torgny)