Skip to content

Commit

Permalink
Add handling for nan values
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbeattie42 committed Oct 21, 2024
1 parent 33445be commit 4ee0e57
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions OpenSim/Common/IO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

#include "Logger.h"
#include <climits>
#include <limits>
#include <math.h>
#include <string>
#include <sstream>
Expand Down Expand Up @@ -482,9 +483,12 @@ stod(const std::string& __str, std::size_t* __idx)
{
std::istringstream iss(__str);
iss.imbue(_locale);
double result = 0.0;
double result;
iss >> result;
log_info("stod str: {}; double: {}", __str, result);
if(iss.fail()){
result = std::numeric_limits<double>::quiet_NaN();
log_warn("Encountered non-numeric string value: {} ; parsed value:{}",__str, result);
}
return result;
}
//_____________________________________________________________________________
Expand Down

0 comments on commit 4ee0e57

Please sign in to comment.