opensim-org / opensim-core

SimTK OpenSim C++ libraries and command-line applications, and Java/Python wrapping.
https://opensim.stanford.edu
Apache License 2.0
800 stars 323 forks source link

[WIP] Minimum stod change #3945

Closed alexbeattie42 closed 1 month ago

alexbeattie42 commented 1 month ago

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 of std::strtod which does mention the locale dependance. To fix this issue I did the following:

Testing I've completed

Looking for feedback on...

Fast_Float

The two options for replacing std::stod are:

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


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 -->