Updated Basic.inl
Fixed StringToNumber not working with lowercase numbers Moved functions order to be alphabetical Former-commit-id: ff58d17afe38c39527a6ae898bfeb7f3282b2142
This commit is contained in:
parent
dc146fdf61
commit
4a0dbcb338
|
|
@ -24,8 +24,6 @@ template<typename T> T NzApproach(T value, T objective, T increment);
|
||||||
template<typename T> constexpr T NzClamp(T value, T min, T max);
|
template<typename T> constexpr T NzClamp(T value, T min, T max);
|
||||||
template<typename T> constexpr T NzDegrees(T degrees);
|
template<typename T> constexpr T NzDegrees(T degrees);
|
||||||
template<typename T> constexpr T NzDegreeToRadian(T degrees);
|
template<typename T> constexpr T NzDegreeToRadian(T degrees);
|
||||||
template<typename T> T NzMultiplyAdd(T x, T y, T z);
|
|
||||||
unsigned int NzIntegralPow(unsigned int base, unsigned int exponent);
|
|
||||||
unsigned int NzGetNearestPowerOfTwo(unsigned int number);
|
unsigned int NzGetNearestPowerOfTwo(unsigned int number);
|
||||||
unsigned int NzGetNumberLength(signed char number);
|
unsigned int NzGetNumberLength(signed char number);
|
||||||
unsigned int NzGetNumberLength(unsigned char number);
|
unsigned int NzGetNumberLength(unsigned char number);
|
||||||
|
|
@ -36,7 +34,9 @@ unsigned int NzGetNumberLength(unsigned long long number);
|
||||||
unsigned int NzGetNumberLength(float number, nzUInt8 precision = NAZARA_CORE_DECIMAL_DIGITS);
|
unsigned int NzGetNumberLength(float number, nzUInt8 precision = NAZARA_CORE_DECIMAL_DIGITS);
|
||||||
unsigned int NzGetNumberLength(double number, nzUInt8 precision = NAZARA_CORE_DECIMAL_DIGITS);
|
unsigned int NzGetNumberLength(double number, nzUInt8 precision = NAZARA_CORE_DECIMAL_DIGITS);
|
||||||
unsigned int NzGetNumberLength(long double number, nzUInt8 precision = NAZARA_CORE_DECIMAL_DIGITS);
|
unsigned int NzGetNumberLength(long double number, nzUInt8 precision = NAZARA_CORE_DECIMAL_DIGITS);
|
||||||
|
unsigned int NzIntegralPow(unsigned int base, unsigned int exponent);
|
||||||
template<typename T, typename T2> T NzLerp(T from, T to, T2 interpolation);
|
template<typename T, typename T2> T NzLerp(T from, T to, T2 interpolation);
|
||||||
|
template<typename T> T NzMultiplyAdd(T x, T y, T z);
|
||||||
template<typename T> T NzNormalizeAngle(T angle);
|
template<typename T> T NzNormalizeAngle(T angle);
|
||||||
template<typename T> bool NzNumberEquals(T a, T b, T maxDifference = std::numeric_limits<T>::epsilon());
|
template<typename T> bool NzNumberEquals(T a, T b, T maxDifference = std::numeric_limits<T>::epsilon());
|
||||||
NzString NzNumberToString(long long number, nzUInt8 radix = 10);
|
NzString NzNumberToString(long long number, nzUInt8 radix = 10);
|
||||||
|
|
|
||||||
|
|
@ -46,46 +46,6 @@ constexpr T NzDegreeToRadian(T degrees)
|
||||||
return degrees * F(M_PI/180.0);
|
return degrees * F(M_PI/180.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
T NzMultiplyAdd(T x, T y, T z)
|
|
||||||
{
|
|
||||||
return x*y + z;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef FP_FAST_FMAF
|
|
||||||
template<>
|
|
||||||
inline float NzMultiplyAdd(float x, float y, float z)
|
|
||||||
{
|
|
||||||
return std::fmaf(x, y, z);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef FP_FAST_FMA
|
|
||||||
template<>
|
|
||||||
inline double NzMultiplyAdd(double x, double y, double z)
|
|
||||||
{
|
|
||||||
return std::fma(x, y, z);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef FP_FAST_FMAL
|
|
||||||
template<>
|
|
||||||
inline long double NzMultiplyAdd(long double x, long double y, long double z)
|
|
||||||
{
|
|
||||||
return std::fmal(x, y, z);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
inline unsigned int NzIntegralPow(unsigned int base, unsigned int exponent)
|
|
||||||
{
|
|
||||||
///TODO: Marquer comme constexpr en C++14
|
|
||||||
unsigned int r = 1;
|
|
||||||
for (unsigned int i = 0; i < exponent; ++i)
|
|
||||||
r *= base;
|
|
||||||
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline unsigned int NzGetNearestPowerOfTwo(unsigned int number)
|
inline unsigned int NzGetNearestPowerOfTwo(unsigned int number)
|
||||||
{
|
{
|
||||||
///TODO: Marquer comme constexpr en C++14
|
///TODO: Marquer comme constexpr en C++14
|
||||||
|
|
@ -181,6 +141,16 @@ inline unsigned int NzGetNumberLength(long double number, nzUInt8 precision)
|
||||||
return NzGetNumberLength(static_cast<long long>(number)) + precision + 1; // Plus un pour le point
|
return NzGetNumberLength(static_cast<long long>(number)) + precision + 1; // Plus un pour le point
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline unsigned int NzIntegralPow(unsigned int base, unsigned int exponent)
|
||||||
|
{
|
||||||
|
///TODO: Marquer comme constexpr en C++14
|
||||||
|
unsigned int r = 1;
|
||||||
|
for (unsigned int i = 0; i < exponent; ++i)
|
||||||
|
r *= base;
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T, typename T2>
|
template<typename T, typename T2>
|
||||||
T NzLerp(T from, T to, T2 interpolation)
|
T NzLerp(T from, T to, T2 interpolation)
|
||||||
{
|
{
|
||||||
|
|
@ -192,6 +162,36 @@ T NzLerp(T from, T to, T2 interpolation)
|
||||||
return from + interpolation*(to - from);
|
return from + interpolation*(to - from);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
T NzMultiplyAdd(T x, T y, T z)
|
||||||
|
{
|
||||||
|
return x*y + z;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef FP_FAST_FMAF
|
||||||
|
template<>
|
||||||
|
inline float NzMultiplyAdd(float x, float y, float z)
|
||||||
|
{
|
||||||
|
return std::fmaf(x, y, z);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef FP_FAST_FMA
|
||||||
|
template<>
|
||||||
|
inline double NzMultiplyAdd(double x, double y, double z)
|
||||||
|
{
|
||||||
|
return std::fma(x, y, z);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef FP_FAST_FMAL
|
||||||
|
template<>
|
||||||
|
inline long double NzMultiplyAdd(long double x, long double y, long double z)
|
||||||
|
{
|
||||||
|
return std::fmal(x, y, z);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
T NzNormalizeAngle(T angle)
|
T NzNormalizeAngle(T angle)
|
||||||
{
|
{
|
||||||
|
|
@ -298,12 +298,13 @@ inline long long NzStringToNumber(NzString str, nzUInt8 radix, bool* ok)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static const char* symbols = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||||
|
|
||||||
str.Simplify();
|
str.Simplify();
|
||||||
if (radix > 10)
|
if (radix > 10)
|
||||||
str.ToUpper();
|
str = str.ToUpper();
|
||||||
|
|
||||||
bool negative = str.StartsWith('-');
|
bool negative = str.StartsWith('-');
|
||||||
static const char* symbols = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
||||||
|
|
||||||
char* digit = &str[(negative) ? 1 : 0];
|
char* digit = &str[(negative) ? 1 : 0];
|
||||||
unsigned long long total = 0;
|
unsigned long long total = 0;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue