Just FYI, there's also a single-method version of this behavior which has been available in the "Ma base additions" package for some years now.. maAsBytesDescription | suffixes | suffixes := { 'k'"ilobytes". 'M'"egabytes". 'G'"igabytes". 'T'"erabytes". 'P'"etabytes". 'E'"xabytes". 'Z'"ettabytes". 'Y'"ottabytes"}. suffixes size to: 1 by: -1 do: [ : index | | units | units := 1000 raisedTo: index. self > units ifTrue: [ ^ ((self / units) asFloat roundTo: 0.01) asString, (suffixes at: index) ] ]. ^ self asString On Sat, Jun 12, 2010 at 10:03 AM, <sebastian@flowingconcept.com> wrote:
Hi there,
I've published a package to help printing measures of bytes in a human readable fashion.
Here is is: http://www.squeaksource.com/Bytes
Examples:
    2 gigabytes asMegabyteString "will give you '2048 MB' if you print it"
for those who have stored half of the galaxy its range goes from kilo to yatto
enjoy
sebastian PS: it uses Aconcagua as foundation so be sure to install it first
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project