[General] Add compareFloats to Utils

fix/skillcap
David Cernat 7 years ago
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…
Cancel
Save