v2 / vlib / v / mathutil / mathutil.v
19 lines · 16 sloc · 407 bytes · 763f94388b1ceff59c3e68ebda2c9f57197f32a4
Raw
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.
4module mathutil
5
6@[inline]
7pub fn min[T](a T, b T) T {
8 return if a < b { a } else { b }
9}
10
11@[inline]
12pub fn max[T](a T, b T) T {
13 return if a > b { a } else { b }
14}
15
16@[inline]
17pub fn abs[T](a T) T {
18 return if a > 0 { a } else { -a }
19}
20