PHP与C#分别格式化文件大小的代码
PHP 版:
C# 版:
代码如下:
function format($size) { $sizetext = array(" B", " KB", " MB", " GB", " TB", " PB", " EB", " ZB", " YB"); return round($size/pow(1024,($i=floor(log($size,1024)))),2).$sizetext[$i]; }
C# 版:
代码如下:
public string formatSize(long size) { if (size == 0) return "0"; string[] sizetext = new string[] { " B", " KB", " MB", " GB", " TB", " PB" }; int i = (int)Math.Floor(Math.Log(size, 1024)); return Math.Round(size / Math.Pow(1024, i), 2).ToString() + sizetext[i]; }
相关推荐
Crazyshark 2020-11-13
缘起宇轩阁 2020-08-15
清风徐来水波不兴 2020-01-14
xishizhaohua 2019-11-19
Nicolase 2019-11-06
左转有出口 2013-10-18
zhangkala 2018-08-05
yuwinter 2012-05-16
CCxiaotang 2009-11-26
zhangwei0php 2019-04-16
phptyong 2019-04-15
的砖栏 2019-04-11
phptyong 2019-04-11
phpyounger 2019-04-10