Blame view

int_util.go 633 Bytes
18fcd6d6b   Marko Tikvić   merged with util ...
1
  package webutility
cacf57bd4   Marko Tikvić   merging with /uti...
2
3
4
  
  import (
  	"fmt"
cacf57bd4   Marko Tikvić   merging with /uti...
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
  )
  
  // ClampInt64 ...
  func ClampInt64(v, min, max int64) int64 {
  	if v < min {
  		return min
  	} else if v > max {
  		return max
  	}
  
  	return v
  }
  
  // InRangeInt64 ...
  func InRangeInt64(v, min, max int64) bool {
  	return (v >= min && v <= max)
  }
cacf57bd4   Marko Tikvić   merging with /uti...
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
  // Int64ToString ...
  func Int64ToString(i int64) string {
  	return fmt.Sprintf("%d", i)
  }
  
  // BoolToInt64 ...
  func BoolToInt64(b bool) int64 {
  	if b {
  		return 1
  	}
  	return 0
  }
  
  // Int64ToBool ...
  func Int64ToBool(i int64) bool {
  	return i != 0
  }
b3f624151   Marko Tikvić   StringToValidInt64()
39

b80ee4b2b   Marko Tikvić   new stuff
40
41
42
43
44
  func MaxInt(vars ...int) (max int) {
  	for _, v := range vars {
  		if v > max {
  			max = v
  		}
b3f624151   Marko Tikvić   StringToValidInt64()
45
  	}
b80ee4b2b   Marko Tikvić   new stuff
46
  	return max
b3f624151   Marko Tikvić   StringToValidInt64()
47
  }