Elin Decompiled Documentation EA 23.300 Nightly
Loading...
Searching...
No Matches
MathEx.cs
Go to the documentation of this file.
1public static class MathEx
2{
3 public static bool IsSameSign(int a, int b)
4 {
5 if (a < 0 || b < 0)
6 {
7 if (a < 0)
8 {
9 return b < 0;
10 }
11 return false;
12 }
13 return true;
14 }
15
16 public static int ClampToInt(long a)
17 {
18 if (a > int.MaxValue)
19 {
20 return int.MaxValue;
21 }
22 if (a < int.MinValue)
23 {
24 return int.MinValue;
25 }
26 return (int)a;
27 }
28
29 public static int ClampToInt(long a, int b = int.MaxValue)
30 {
31 if (a > b)
32 {
33 return b;
34 }
35 if (a < -b)
36 {
37 return -b;
38 }
39 return (int)a;
40 }
41
42 public static long Max(long a, long b)
43 {
44 if (a >= b)
45 {
46 return a;
47 }
48 return b;
49 }
50}
Definition: MathEx.cs:2
static int ClampToInt(long a, int b=int.MaxValue)
Definition: MathEx.cs:29
static long Max(long a, long b)
Definition: MathEx.cs:42
static bool IsSameSign(int a, int b)
Definition: MathEx.cs:3
static int ClampToInt(long a)
Definition: MathEx.cs:16