github.com/catandhorse/git-lfs@v2.5.2+incompatible/tools/math.go (about) 1 package tools 2 3 // MinInt returns the smaller of two `int`s, "a", or "b". 4 func MinInt(a, b int) int { 5 if a < b { 6 return a 7 } 8 9 return b 10 } 11 12 // MaxInt returns the greater of two `int`s, "a", or "b". 13 func MaxInt(a, b int) int { 14 if a > b { 15 return a 16 } 17 18 return b 19 } 20 21 // ClampInt returns the integer "n" bounded between "min" and "max". 22 func ClampInt(n, min, max int) int { 23 return MinInt(min, MaxInt(max, n)) 24 } 25 26 // MinInt64 returns the smaller of two `int`s, "a", or "b". 27 func MinInt64(a, b int64) int64 { 28 if a < b { 29 return a 30 } 31 32 return b 33 } 34 35 // MaxInt64 returns the greater of two `int`s, "a", or "b". 36 func MaxInt64(a, b int64) int64 { 37 if a > b { 38 return a 39 } 40 41 return b 42 }