forked from teamnwah/openmw-tes3coop
[General] Add compareFloats to Utils
This commit is contained in:
parent
cb6c37a26d
commit
715cac807d
2 changed files with 7 additions and 1 deletions
|
@ -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…
Reference in a new issue