summaryrefslogtreecommitdiff
path: root/src/util/util.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/util.go')
-rw-r--r--src/util/util.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/util/util.go b/src/util/util.go
index 14833c04..1f53cc76 100644
--- a/src/util/util.go
+++ b/src/util/util.go
@@ -27,6 +27,17 @@ func Max32(first int32, second int32) int32 {
return second
}
+// Constrain32 limits the given 32-bit integer with the upper and lower bounds
+func Constrain32(val int32, min int32, max int32) int32 {
+ if val < min {
+ return min
+ }
+ if val > max {
+ return max
+ }
+ return val
+}
+
// Constrain limits the given integer with the upper and lower bounds
func Constrain(val int, min int, max int) int {
if val < min {