The above fixed the reading/writing problems but the code was still failing. Even with the imbuing of the input and output file stream, the parser converting strings to decimals is still using the system locale. After enough digging and exploration I found that std::stod is locale dependent. It is a thinly veiled wrapper of std::strtod which does mention the locale dependance. To fix this issue I did the following:
Create a method with the same signature as std::stod in the IO.h class
Implement a string to decimal conversion that is invariate to the system specified locale (the two potential methods are described below)
Replace all calls to std::stod with the new IO::stod method
std::stod (not a solution because of locale dependence but nice to compare to)
Runtime = 159572281[µs] = 159 seconds
I conducted these tests using the sample program linked above. I don't see a reason to not use the fast library but if there is opposition to including another library the `istringstream` method would also work.
### CHANGELOG.md (choose one)
- When things are reviewed and ready I can also add some more comments
- Will update once it is reviewed and approved to avoid continually rebasing against changelog conflicts while it is under review.
<!-- Reviewable:start -->
- - -
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/opensim-org/opensim-core/3945)
<!-- Reviewable:end -->
Fixes issue #3924
Brief summary of changes
String to Decimal Conversion
The above fixed the reading/writing problems but the code was still failing. Even with the imbuing of the input and output file stream, the parser converting strings to decimals is still using the system locale. After enough digging and exploration I found that
std::stod
is locale dependent. It is a thinly veiled wrapper ofstd::strtod
which does mention the locale dependance. To fix this issue I did the following:std::stod
in theIO.h
classstd::stod
with the newIO::stod
methodTesting I've completed
Looking for feedback on...
Fast_Float
The two options for replacing
std::stod
are:isstream
method (standard c++):fast_float
In my preliminary testing on my machine against the three methods I got these results for program runtime:
istringstream
Runtime = 156114023[µs] = 156 seconds
std::stod (not a solution because of locale dependence but nice to compare to)
Runtime = 159572281[µs] = 159 seconds