Issue 5951 in pharo: Add #asBytesDescription to Number

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Issue 5951 in pharo: Add #asBytesDescription to Number

pharo
Status: Accepted
Owner: marianopeck
Labels: Type-Bug

New issue 5951 by marianopeck: Add #asBytesDescription to Number
http://code.google.com/p/pharo/issues/detail?id=5951

This is something took from Magma and it is very nice to visualize unit of  
measure to bytes. It gets the most approx. suffix and prints it that way.

Example: 1080000 asBytesDescription -> '1.08M'
10800 asBytesDescription -> '10.8k'

wanna include it in Pharo?

Number >> asBytesDescription
        | 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


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 5951 in pharo: Add #asBytesDescription to Number

pharo
Updates:
        Labels: -Type-Bug Type-Feature Difficulty-Easy Milestone-2.0

Comment #1 on issue 5951 by marianopeck: Add #asBytesDescription to Number
http://code.google.com/p/pharo/issues/detail?id=5951

(No comment was entered for this change.)


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 5951 in pharo: Add #asBytesDescription to Number

pharo
Updates:
        Status: Invalid

Comment #2 on issue 5951 by marianopeck: Add #asBytesDescription to Number
http://code.google.com/p/pharo/issues/detail?id=5951

wtf....it was already integrated....grrr sorry.


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker