| 1 | // Copyright (c) 2019-2024 Alexander Medvednikov. All rights reserved. |
| 2 | // Use of this source code is governed by an MIT license |
| 3 | // that can be found in the LICENSE file. |
| 4 | module mathutil |
| 5 | |
| 6 | @[inline] |
| 7 | pub fn min[T](a T, b T) T { |
| 8 | return if a < b { a } else { b } |
| 9 | } |
| 10 | |
| 11 | @[inline] |
| 12 | pub fn max[T](a T, b T) T { |
| 13 | return if a > b { a } else { b } |
| 14 | } |
| 15 | |
| 16 | @[inline] |
| 17 | pub fn abs[T](a T) T { |
| 18 | return if a > 0 { a } else { -a } |
| 19 | } |
| 20 |