Return to Snippet

Revision: 24961
at March 16, 2010 18:24 by rondog


Initial Code
public static function readablizeBytes(bytes:uint):String
{
	var s:Array 	= ['bytes', 'kb', 'MB', 'GB', 'TB', 'PB'];
	var e:Number 	= Math.floor( Math.log( bytes ) / Math.log( 1024 ) );
	return ( bytes / Math.pow( 1024, Math.floor( e ) ) ).toFixed( 2 ) + " " + s[e];
}

Initial URL
http://activeden.net/user/rondog?ref=rondog

Initial Description
this will convert bytes to a readable format with 2 decimal places

Initial Title
Bytes to Readable format (bytes, kb, mb etc)

Initial Tags
format

Initial Language
ActionScript