fix error: 0 is No number

This commit is contained in:
Markus 2019-09-01 10:32:11 +02:00
parent 34c1fc637f
commit c021a655dd

View File

@ -939,12 +939,16 @@ bool nothingExists(std::string path)

bool isNumber(std::string number)
{
for (size_t i = 0; i < number.length(); ++i) {
bool hasRemovedZero = false;
for (size_t i = 0; i < number.length(); ++i)
if( number[i] == '0') {
number.erase(i, 1);
i--;
hasRemovedZero=true;
}
}
if(hasRemovedZero && number == "")
number="0";

return (std::to_string(atoll(number.c_str())) == number) ? true : false;
}