| 1 |
/* |
| 2 |
Copyright 2016 The Kubernetes Authors. |
| 3 |
|
| 4 |
Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 |
you may not use this file except in compliance with the License. |
| 6 |
You may obtain a copy of the License at |
| 7 |
|
| 8 |
http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
|
| 10 |
Unless required by applicable law or agreed to in writing, software |
| 11 |
distributed under the License is distributed on an "AS IS" BASIS, |
| 12 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 |
See the License for the specific language governing permissions and |
| 14 |
limitations under the License. |
| 15 |
*/ |
| 16 |
|
| 17 |
package integer |
| 18 |
|
| 19 |
import "math" |
| 20 |
|
| 21 |
// IntMax returns the maximum of the params. |
| 22 |
// Deprecated: for new code, use the max() builtin instead. |
| 23 |
func IntMax(a, b int) int { |
| 24 |
if b > a { |
| 25 |
return b |
| 26 |
} |
| 27 |
return a |
| 28 |
} |
| 29 |
|
| 30 |
// IntMin returns the minimum of the params. |
| 31 |
// Deprecated: for new code, use the min() builtin instead. |
| 32 |
func IntMin(a, b int) int { |
| 33 |
if b < a { |
| 34 |
return b |
| 35 |
} |
| 36 |
return a |
| 37 |
} |
| 38 |
|
| 39 |
// Int32Max returns the maximum of the params. |
| 40 |
// Deprecated: for new code, use the max() builtin instead. |
| 41 |
func Int32Max(a, b int32) int32 { |
| 42 |
if b > a { |
| 43 |
return b |
| 44 |
} |
| 45 |
return a |
| 46 |
} |
| 47 |
|
| 48 |
// Int32Min returns the minimum of the params. |
| 49 |
// Deprecated: for new code, use the min() builtin instead. |
| 50 |
func Int32Min(a, b int32) int32 { |
| 51 |
if b < a { |
| 52 |
return b |
| 53 |
} |
| 54 |
return a |
| 55 |
} |
| 56 |
|
| 57 |
// Int64Max returns the maximum of the params. |
| 58 |
// Deprecated: for new code, use the max() builtin instead. |
| 59 |
func Int64Max(a, b int64) int64 { |
| 60 |
if b > a { |
| 61 |
return b |
| 62 |
} |
| 63 |
return a |
| 64 |
} |
| 65 |
|
| 66 |
// Int64Min returns the minimum of the params. |
| 67 |
// Deprecated: for new code, use the min() builtin instead. |
| 68 |
func Int64Min(a, b int64) int64 { |
| 69 |
if b < a { |
| 70 |
return b |
| 71 |
} |
| 72 |
return a |
| 73 |
} |
| 74 |
|
| 75 |
// RoundToInt32 rounds floats into integer numbers. |
| 76 |
// Deprecated: use math.Round() and a cast directly. |
| 77 |
func RoundToInt32(a float64) int32 { |
| 78 |
return int32(math.Round(a)) |
| 79 |
} |