mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-07-21 06:14:05 +00:00
[General] Add getNumberOfDigits to Utils in components
This commit is contained in:
parent
f410cb90d8
commit
ae55ee7f0b
2 changed files with 14 additions and 1 deletions
|
@ -54,7 +54,7 @@ void Utils::timestamp()
|
||||||
printf("%s", t);
|
printf("%s", t);
|
||||||
}
|
}
|
||||||
|
|
||||||
// http://stackoverflow.com/questions/1637587/c-libcurl-console-progress-bar
|
// Based on http://stackoverflow.com/questions/1637587/c-libcurl-console-progress-bar
|
||||||
int Utils::progressFunc(double TotalToDownload, double NowDownloaded)
|
int Utils::progressFunc(double TotalToDownload, double NowDownloaded)
|
||||||
{
|
{
|
||||||
// how wide you want the progress meter to be
|
// how wide you want the progress meter to be
|
||||||
|
@ -85,6 +85,18 @@ bool Utils::compareDoubles(double a, double b, double epsilon)
|
||||||
return fabs(a - b) < epsilon;
|
return fabs(a - b) < epsilon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Based on https://stackoverflow.com/a/1489873
|
||||||
|
unsigned int Utils::getNumberOfDigits(int integer)
|
||||||
|
{
|
||||||
|
int digits = 0;
|
||||||
|
if (integer < 0) digits = 1;
|
||||||
|
while (integer) {
|
||||||
|
integer /= 10;
|
||||||
|
digits++;
|
||||||
|
}
|
||||||
|
return digits;
|
||||||
|
}
|
||||||
|
|
||||||
std::string Utils::toString(int num)
|
std::string Utils::toString(int num)
|
||||||
{
|
{
|
||||||
std::ostringstream stream;
|
std::ostringstream stream;
|
||||||
|
|
|
@ -26,6 +26,7 @@ namespace Utils
|
||||||
|
|
||||||
int progressFunc(double TotalToDownload, double NowDownloaded);
|
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);
|
||||||
|
|
||||||
template <class Type, class Type2>
|
template <class Type, class Type2>
|
||||||
|
|
Loading…
Reference in a new issue