INNER CODE UNIT · Go

ReadableFileSize

benbusby/yeetfile · shared/utils.go:20

func ReadableFileSize(b int64) string {
	if b < 0 {
		return "Unlimited"
	}

	const unit = 1000
	if b < unit {
		return fmt.Sprintf("%d B", b)
	}

	div, exp := int64(unit), 0
	for n := b / unit; n >= unit; n /= unit {
		div *= unit
		exp++
	}

	size := float64(b) / float64(div)
	if math.Mod(size, 1) == 0 {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…