mirror of
https://github.com/TES3MP/TES3MP.git
synced 2025-09-26 14:36:40 -04:00
[General] Add compareFloats to Utils
This commit is contained in:
parent
cb6c37a26d
commit
715cac807d
@ -91,6 +91,11 @@ bool Utils::compareDoubles(double a, double b, double epsilon)
|
||||
return fabs(a - b) < epsilon;
|
||||
}
|
||||
|
||||
bool Utils::compareFloats(float a, float b, float epsilon)
|
||||
{
|
||||
return fabs(a - b) < epsilon;
|
||||
}
|
||||
|
||||
// Based on https://stackoverflow.com/a/1489873
|
||||
unsigned int Utils::getNumberOfDigits(int integer)
|
||||
{
|
||||
|
@ -28,7 +28,8 @@ namespace Utils
|
||||
int progressFunc(double TotalToDownload, double NowDownloaded);
|
||||
|
||||
unsigned int getNumberOfDigits(int integer);
|
||||
bool compareDoubles(double a, double b, double epsilon);
|
||||
bool compareDoubles(double a, double b, double epsilon = 0.005);
|
||||
bool compareFloats(float a, float b, float epsilon = 0.005f);
|
||||
|
||||
template <class Type, class Type2>
|
||||
bool vectorContains(const std::vector<Type> &vectorChecked, const Type2 &value)
|
||||
|
Loading…
x
Reference in New Issue
Block a user