add K/M/B/T to output
This commit is contained in:
parent
b319e29be8
commit
2262d5b617
|
@ -85,6 +85,8 @@ function f(){
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Note that these sed commands are just hacks, and won't parse e.g., `3.5K` correctly—it will just substitute for 3.5000
|
||||||
|
|
||||||
## Tips & tricks
|
## Tips & tricks
|
||||||
|
|
||||||
Conceptually clearer to have all the multiplications first and then all the divisions
|
Conceptually clearer to have all the multiplications first and then all the divisions
|
||||||
|
|
40
f.go
40
f.go
|
@ -40,6 +40,42 @@ func combineBounds(old_low, old_high, new_low, new_high float64) (float64, float
|
||||||
return logParamsToBounds(logmean_product, logstd_product)
|
return logParamsToBounds(logmean_product, logstd_product)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func prettyPrintDist(low float64, high float64) {
|
||||||
|
// fmt.Printf("=> %.1f %.1f\n", low, high)
|
||||||
|
fmt.Printf("=> ")
|
||||||
|
switch {
|
||||||
|
case math.Abs(low) >= 1_000_000_000_000:
|
||||||
|
fmt.Printf("%.1fT", low/1_000_000_000_000)
|
||||||
|
case math.Abs(low) >= 1_000_000_000:
|
||||||
|
fmt.Printf("%.1fB", low/1_000_000_000)
|
||||||
|
case math.Abs(low) >= 1_000_000:
|
||||||
|
fmt.Printf("%.1fM", low/1_000_000)
|
||||||
|
case math.Abs(low) >= 1_000:
|
||||||
|
fmt.Printf("%.1fK", low/1_000)
|
||||||
|
case math.Abs(low) >= 1_000:
|
||||||
|
fmt.Printf("%.1fK", low/1_000)
|
||||||
|
default:
|
||||||
|
fmt.Printf("%.1f", low)
|
||||||
|
}
|
||||||
|
fmt.Printf(" ")
|
||||||
|
switch {
|
||||||
|
case math.Abs(high) >= 1_000_000_000_000:
|
||||||
|
fmt.Printf("%.1fT", high/1_000_000_000_000)
|
||||||
|
case math.Abs(high) >= 1_000_000_000:
|
||||||
|
fmt.Printf("%.1fB", high/1_000_000_000)
|
||||||
|
case math.Abs(high) >= 1_000_000:
|
||||||
|
fmt.Printf("%.1fM", high/1_000_000)
|
||||||
|
case math.Abs(high) >= 1_000:
|
||||||
|
fmt.Printf("%.1fK", high/1_000)
|
||||||
|
case math.Abs(high) >= 1_000:
|
||||||
|
fmt.Printf("%.1fK", high/1_000)
|
||||||
|
default:
|
||||||
|
fmt.Printf("%.1f", high)
|
||||||
|
}
|
||||||
|
fmt.Printf("\n")
|
||||||
|
// fmt.Printf("=> %.1f %.1f\n", low, high)
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
reader := bufio.NewReader(os.Stdin)
|
reader := bufio.NewReader(os.Stdin)
|
||||||
|
|
||||||
|
@ -79,7 +115,7 @@ InitialForLoop:
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
fmt.Printf("=> %.1f %.1f\n", old_low, old_high)
|
prettyPrintDist(old_low, old_high)
|
||||||
|
|
||||||
error_msg_cont := "Valid inputs: 2 || * 2 || / 2 || 2 20 || * 2 20 || / 2 20 || i || e"
|
error_msg_cont := "Valid inputs: 2 || * 2 || / 2 || 2 20 || * 2 20 || / 2 20 || i || e"
|
||||||
EventForLoop:
|
EventForLoop:
|
||||||
|
@ -189,6 +225,6 @@ EventForLoop:
|
||||||
}
|
}
|
||||||
|
|
||||||
old_low, old_high = combineBounds(old_low, old_high, new_low, new_high)
|
old_low, old_high = combineBounds(old_low, old_high, new_low, new_high)
|
||||||
fmt.Printf("=> %.1f %.1f\n", old_low, old_high)
|
prettyPrintDist(old_low, old_high)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user