修改TB、PB、EB的有些计算错误

This commit is contained in:
GoEdgeLab
2021-04-29 15:04:42 +08:00
parent 746ecd1e41
commit 15b687bb01
4 changed files with 21 additions and 3 deletions

View File

@@ -22,8 +22,12 @@ func FormatBytes(bytes int64) string {
return fmt.Sprintf("%.2fMB", float64(bytes)/1024/1024) return fmt.Sprintf("%.2fMB", float64(bytes)/1024/1024)
} else if bytes < 1024*1024*1024*1024 { } else if bytes < 1024*1024*1024*1024 {
return fmt.Sprintf("%.2fGB", float64(bytes)/1024/1024/1024) return fmt.Sprintf("%.2fGB", float64(bytes)/1024/1024/1024)
} else if bytes < 1024*1024*1024*1024*1024 {
return fmt.Sprintf("%.2fTB", float64(bytes)/1024/1024/1024/1024)
} else if bytes < 1024*1024*1024*1024*1024*1024 {
return fmt.Sprintf("%.2fPB", float64(bytes)/1024/1024/1024/1024/1024)
} else { } else {
return fmt.Sprintf("%.2fPB", float64(bytes)/1024/1024/1024/1024) return fmt.Sprintf("%.2fEB", float64(bytes)/1024/1024/1024/1024/1024/1024)
} }
} }
@@ -36,7 +40,11 @@ func FormatBits(bits int64) string {
return fmt.Sprintf("%.2fMB", float64(bits)/1000/1000) return fmt.Sprintf("%.2fMB", float64(bits)/1000/1000)
} else if bits < 1000*1000*1000*1000 { } else if bits < 1000*1000*1000*1000 {
return fmt.Sprintf("%.2fGB", float64(bits)/1000/1000/1000) return fmt.Sprintf("%.2fGB", float64(bits)/1000/1000/1000)
} else if bits < 1000*1000*1000*1000*1000 {
return fmt.Sprintf("%.2fTB", float64(bits)/1000/1000/1000/1000)
} else if bits < 1000*1000*1000*1000*1000*1000 {
return fmt.Sprintf("%.2fPB", float64(bits)/1000/1000/1000/1000/1000)
} else { } else {
return fmt.Sprintf("%.2fPB", float64(bits)/1000/1000/1000/1000) return fmt.Sprintf("%.2fEB", float64(bits)/1000/1000/1000/1000/1000/1000)
} }
} }

View File

@@ -77,8 +77,10 @@ func (this *PricesAction) formatBits(bits int64) string {
sizeHuman = fmt.Sprintf("%.2fGBPS", float64(bits)/1000/1000/1000) sizeHuman = fmt.Sprintf("%.2fGBPS", float64(bits)/1000/1000/1000)
} else if bits < 1_000_000_000_000_000 { } else if bits < 1_000_000_000_000_000 {
sizeHuman = fmt.Sprintf("%.2fTBPS", float64(bits)/1000/1000/1000/1000) sizeHuman = fmt.Sprintf("%.2fTBPS", float64(bits)/1000/1000/1000/1000)
} else { } else if bits < 1_000_000_000_000_000_000 {
sizeHuman = fmt.Sprintf("%.2fPBPS", float64(bits)/1000/1000/1000/1000/1000) sizeHuman = fmt.Sprintf("%.2fPBPS", float64(bits)/1000/1000/1000/1000/1000)
} else {
sizeHuman = fmt.Sprintf("%.2fEBPS", float64(bits)/1000/1000/1000/1000/1000/1000)
} }
return sizeHuman return sizeHuman
} }

View File

@@ -37,6 +37,10 @@ Tea.context(function () {
return (bits / 1000 / 1000 / 1000) + "PB" return (bits / 1000 / 1000 / 1000) + "PB"
} }
if (bits < 1000 * 1000 * 1000 * 1000 * 1000) {
return (bits / 1000 / 1000 / 1000 / 1000) + "EB"
}
return "" return ""
} }
}) })

View File

@@ -40,6 +40,10 @@ Tea.context(function () {
return (bits / 1000 / 1000 / 1000) + "PB" return (bits / 1000 / 1000 / 1000) + "PB"
} }
if (bits < 1000 * 1000 * 1000 * 1000 * 1000) {
return (bits / 1000 / 1000 / 1000 / 1000) + "EB"
}
return "" return ""
} }
}) })