Skip to content

Commit

Permalink
nan/inf support
Browse files Browse the repository at this point in the history
  • Loading branch information
jschueller committed Dec 12, 2024
1 parent 9f8a721 commit 4e60f41
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions single_include/csv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5369,6 +5369,24 @@ namespace csv {

return DataType::CSV_STRING;
break;
case 'i':
case 'I':
if(i + 2 < ilen && in[i + 1] == 'n' && in[i+2] == 'f') {
if (out) {
*out = is_negative ? -std::numeric_limits<double>::infinity() : std::numeric_limits<double>::infinity();
}
return DataType::CSV_DOUBLE;
}
return DataType::CSV_STRING;
case 'n':
case 'N':
if(i + 2 < ilen && in[i + 1] == 'a' && std::tolower(in[i + 2]) == 'n') {
if (out) {
*out = is_negative ? -std::numeric_limits<double>::quiet_NaN() : std::numeric_limits<double>::quiet_NaN();
}
return DataType::CSV_DOUBLE;
}
return DataType::CSV_STRING;
default:
short digit = static_cast<short>(current - '0');
if (digit >= 0 && digit <= 9) {
Expand Down

0 comments on commit 4e60f41

Please sign in to comment.