4#ifndef _Stroika_Foundation_Math_Common_h_
5#define _Stroika_Foundation_Math_Common_h_ 1
7#include "Stroika/Foundation/StroikaPreComp.h"
15#include "Stroika/Foundation/Common/Concepts.h"
29namespace Stroika::Foundation::Math {
34 template <
floating_po
int T =
double>
39 template <
floating_po
int T =
double>
40 constexpr T infinity ();
44 [[deprecated (
"Since C++20, use std::numbers::e_v")]]
constexpr double kE = numbers::e_v<double>;
48 [[deprecated (
"Since C++20, use std::numbers::pi_v")]]
constexpr double kPi = numbers::pi_v<double>;
59 template <Common::IBuiltinArithmetic T>
60 constexpr T RoundUpTo (T x, T toNearest);
69 template <Common::IBuiltinArithmetic T>
70 constexpr T RoundDownTo (T x, T toNearest);
99 template <
integral INT_TYPE,
floating_po
int FLOAT_TYPE>
100 constexpr INT_TYPE Round (FLOAT_TYPE n);
101 template <
floating_po
int FLOAT_TYPE>
102 FLOAT_TYPE Round (FLOAT_TYPE n,
unsigned int nDigitsOfPrecision);
109 template <
integral INT_TYPE,
floating_po
int FLOAT_TYPE>
110 constexpr INT_TYPE Trunc (FLOAT_TYPE n);
143 template <Common::IBuiltinArithmetic T1, Common::IBuiltinArithmetic T2>
144 constexpr bool NearlyEquals (T1 l, T2 r);
145 template <Common::IBuiltinArithmetic T1, Common::IBuiltinArithmetic T2,
typename EPSILON_TYPE>
146 constexpr bool NearlyEquals (T1 l, T2 r, EPSILON_TYPE epsilon);
161 template <
floating_po
int T>
162 constexpr T PinToSpecialPoint (T p, T special);
163 template <
floating_po
int T>
164 constexpr T PinToSpecialPoint (T p, T special, T epsilon);
172 template <
typename T>
173 constexpr T AtLeast (T initialValue, T lowerBound);
181 template <
typename T>
182 constexpr T AtMost (T initialValue, T upperBound);
198 template <
typename NEW_T,
typename T>
199 constexpr NEW_T PinToMaxForType (T initialValue);
207 template <Common::IBuiltinArithmetic T,
typename RESULT_TYPE = T>
208 constexpr RESULT_TYPE Abs (T v);
213 template <
integral T>
214 constexpr bool IsOdd (T v);
219 template <
integral T>
220 constexpr bool IsEven (T v);
230 template <
integral T>