ããã¡ãã£ã(//â½//
ã¡ããã¨æ¢ãã°ããããã ãã©è¦ã¤ãããªãã®ã§â¦
ããã¡ãã£ã(//â½//
æ°åãKB,MB,GBçã«å¤æããé¢æ°
(function($size,$fixed,$unit){ return function($size,$fixed,$unit){ var $len = ($size.length > $unit.length ? $unit.length : $size.length) - 1; return { size : Number($len > 1 ? $size[$len] + '.' + $size[$len-1] : $size[$len]).toFixed($fixed), unit : $unit[$len], toString: function(){return this.size+this.unit} }; }( ( function($size){ while($size != ($size = $size.replace(/^(-?\d+)(\d{3})/, "$1,$2"))); return $size; }( new String($size) ) ).split(/,/).reverse(), typeof($fixed) === 'undefined' ? 0 : $fixed, typeof($unit ) === 'undefined' ? 'Byte,KB,MB,GB,TB,PB,EB,ZB,YB'.split(/,/) : $unit ); }(Math.pow(10,9),2) ).toString();
æ°åãKB,MB,GBçã«å¤æããé¢æ°(ç°¡æç,2^10ã§è¨ç®)
(function($size){ return function($size,$){ var $unit = $.shift(),$_; while( ( $_ = $size >> 10 ) >= 1 ) $unit = $.shift(),$size = $_; return $size + $unit; }(Number($size),'Byte,KB,MB,GB,TB,PB,EB,ZB,YB'.split(/,/)); })(0.5*Math.pow(2,30));
ç¡åé¢æ°ã®ã¾ã¾ããããããããªã®ã§ååä»ãã¦ããããã£ã¦ããã¦ï¼