Monday, November 08, 2010 at 12:05 AM.
system.verbs.builtins.string.megabyteString
on megabyteString (size) { <<display size in megabytes, the next step after string.kBytes
<<New verb: 11/9/97 at 8:40:40 AM by DW
<<Change notes:
<<Tue, Jul 28, 1998 at 10:03:23 AM by PBS
<<Fixed small math bug.
local (onemeg = 1024 * 1024);
if size <= onemeg {
return (string.kBytes (size))};
size = size + (onemeg / 20);
local (leftofdecimal = size / onemeg);
local (numerator = size % onemeg);
local (denominator = double (onemeg / 10));
local (rightofdecimal = string (numerator / denominator));
if sizeOf (rightofdecimal) > 1 {
rightofdecimal = rightofdecimal [1]};
local (s = leftofdecimal + "." + rightofdecimal);
return (s + "MB")}
This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.