PGE Engine
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Pages
maths.h
1 #ifndef MATHS_H
2 #define MATHS_H
3 #include <type_traits>
4 
5 class Maths
6 {
7 public:
8  static long roundTo(long src, long grid);
9  static double roundTo(double src, double grid);
10 
11  template <typename T>
12  static T max(T n1, T n2) {
13  static_assert(std::is_arithmetic<T>::value, "The value for \"max\" must be arithemtic");
14  return (n1>n2) ? n1 : n2;
15  }
16 
17  template <typename T>
18  static T min(T n1, T n2) {
19  static_assert(std::is_arithmetic<T>::value, "The value for \"min\" must be arithemtic");
20  return (n1<n2) ? n1 : n2;
21  }
22 
23  template <typename T>
24  static int sgn(T val) {
25  static_assert(std::is_arithmetic<T>::value, "The value for \"val\" must be arithemtic");
26  return int(T(0) < val) - int(val < T(0));
27  }
28 };
29 
30 #endif // MATHS_H
Definition: maths.h:5