/ Published in: ActionScript

this will convert bytes to a readable format with 2 decimal places
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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]; }
URL: http://activeden.net/user/rondog?ref=rondog
Comments
