Avoid implicit conversions from signed to unsigned
[openal-soft.git] / common / math_defs.h
blob9749bd532581408c815cb7b90e8003ddedd40231
1 #ifndef AL_MATH_DEFS_H
2 #define AL_MATH_DEFS_H
4 #include <math.h>
6 #ifndef M_PI
7 #define M_PI 3.14159265358979323846
8 #endif
10 constexpr inline float Deg2Rad(float x) noexcept { return x * static_cast<float>(M_PI/180.0); }
11 constexpr inline float Rad2Deg(float x) noexcept { return x * static_cast<float>(180.0/M_PI); }
13 namespace al {
15 template<typename Real>
16 struct MathDefs { };
18 template<>
19 struct MathDefs<float> {
20 static constexpr inline float Pi() noexcept { return 3.14159265358979323846f; }
21 static constexpr inline float Tau() noexcept { return 3.14159265358979323846f * 2.0f; }
22 static constexpr inline float Sqrt3() noexcept { return 1.73205080756887719318f; }
25 template<>
26 struct MathDefs<double> {
27 static constexpr inline double Pi() noexcept { return 3.14159265358979323846; }
28 static constexpr inline double Tau() noexcept { return 3.14159265358979323846 * 2.0; }
29 static constexpr inline double Sqrt3() noexcept { return 1.73205080756887719318; }
32 } // namespace al
34 #endif /* AL_MATH_DEFS_H */