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
Post a Comment