c++ - Using atof for integer -


i've inherited code (from has left) , found little snippet:

double minx = xval.find('.') == string::npos ? (double)atoi(xval.c_str()) : atof(xval.c_str()); double miny = yval.find('.') == string::npos ? (double)atoi(yval.c_str()) : atof(yval.c_str()); 

is there reason why chose use atoi integer types? can't see problem with:

double minx = atof(xval.c_str()); double miny = atof(yval.c_str()); 

thanks.

no reason. these ternary operators extra. better use strtod instead atof - atof not detect overflow , underflow errors.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -