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) { ...@@ -148,17 +148,19 @@ inline static const char* Atof(const char* p, double* out) {
&& *(p + cnt) != ':') { && *(p + cnt) != ':') {
++cnt; ++cnt;
} }
std::string tmp_str(p, cnt); if(cnt > 0){
std::transform(tmp_str.begin(), tmp_str.end(), tmp_str.begin(), ::tolower); std::string tmp_str(p, cnt);
if (tmp_str == std::string("na") || tmp_str == std::string("nan")) { std::transform(tmp_str.begin(), tmp_str.end(), tmp_str.begin(), ::tolower);
*out = 0; if (tmp_str == std::string("na") || tmp_str == std::string("nan")) {
} else if( tmp_str == std::string("inf") || tmp_str == std::string("infinity")) { *out = 0;
*out = sign * 1e308; } 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()); else {
Log::Stderr("Unknow token %s in data file", tmp_str.c_str());
}
p += cnt;
} }
p += cnt;
} }
while (*p == ' ') { 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