我正在执行以下代码,但是static func prettyBytes(_ numBytes: UInt64) -> String {
let scale: UInt64 = 1_024
let abbrevs = [ "EB", "PB", "TB", "GB", "MB", "KB", "Bytes" ]
var maximum = UInt64(powl(Double(scale), Double(abbrevs.count - 1)))
for abbrev in abbrevs {
if numBytes > maximum {
return String(format: "%.4f %@", Double(numBytes) / Double(maximum), abbrev)
}
maximum /= scale
}
return String(format: "%u Bytes", numBytes)
}
字段没有更新:
cash