Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
41 lines (32 sloc) 460 Bytes
package main
import "math"
func maxInt(a, b int) int {
if a > b {
return a
}
return b
}
func minInt(a, b int) int {
if a < b {
return a
}
return b
}
func minNonZeroInt(a, b int) int {
switch {
case a == 0:
return b
case b == 0:
return a
}
return minInt(a, b)
}
func roundToInt(a float64) int {
return int(math.Round(a))
}
func scaleInt(a int, scale float64) int {
if a == 0 {
return 0
}
return roundToInt(float64(a) * scale)
}
You can’t perform that action at this time.