Commit 44c201c4 authored by Guolin Ke's avatar Guolin Ke Committed by GitHub
Browse files

bug fixed in atof

parent 7d4b6d44
......@@ -148,17 +148,19 @@ inline static const char* Atof(const char* p, double* out) {
&& *(p + cnt) != ':') {
++cnt;
}
std::string tmp_str(p, cnt);
std::transform(tmp_str.begin(), tmp_str.end(), tmp_str.begin(), ::tolower);
if (tmp_str == std::string("na") || tmp_str == std::string("nan")) {
*out = 0;
} else if( tmp_str == std::string("inf") || tmp_str == std::string("infinity")) {
*out = sign * 1e308;
}
else {
Log::Stderr("Unknow token %s in data file", tmp_str.c_str());
if(cnt > 0){
std::string tmp_str(p, cnt);
std::transform(tmp_str.begin(), tmp_str.end(), tmp_str.begin(), ::tolower);
if (tmp_str == std::string("na") || tmp_str == std::string("nan")) {
*out = 0;
} else if( tmp_str == std::string("inf") || tmp_str == std::string("infinity")) {
*out = sign * 1e308;
}
else {
Log::Stderr("Unknow token %s in data file", tmp_str.c_str());
}
p += cnt;
}
p += cnt;
}
while (*p == ' ') {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment