Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

manager: replace stod by boost spirit parsing #399

Closed
wants to merge 1 commit into from

Conversation

rtrepos
Copy link
Member

@rtrepos rtrepos commented Aug 22, 2024

Using cvle, the reading of double from char* can lead to error when value is very low. (as mentionned here https://stackoverflow.com/questions/48086830/stdstod-throws-out-of-range-error-for-a-string-that-should-be-valid) We prefer using the boost spirit parsing as in the SaxParser code.

@quesnel
Copy link
Member

quesnel commented Aug 22, 2024

You can use the traditional C function strtod (in cstdlib [1]) to convert string to double without exception and error. I rewrite the example: [2].

[1] https://en.cppreference.com/w/c/string/byte/strtof
[2] https://www.godbolt.org/z/7W44xbq3h

@rtrepos
Copy link
Member Author

rtrepos commented Aug 22, 2024

Ok thank you goth.
It worked by solving my issue.
But the idea also was to be sure to have the same behavior when with use the parallelization or not. In one case we would rely on boost spirit, on the other on the strtod. Do you think it is the case ?

Also, If i throw an exception on the test errno == ERANGE, I systematically get one error (my example make a read of many values). It worked if I preset errno to 0 before the call to strtod. Is that the way to do it ?

@quesnel
Copy link
Member

quesnel commented Aug 26, 2024 via email

 Using cvle, the reading of double from char* can lead to error when value is very low.
 (as mentionned here https://stackoverflow.com/questions/48086830/stdstod-throws-out-of-range-error-for-a-string-that-should-be-valid)
 This error does not occur with the C function strtod.
@rtrepos
Copy link
Member Author

rtrepos commented Aug 26, 2024

Ok thank you, I stoped the CI/CD checks (that were still waiting for ressources) and I close this pull request and I push new commits on master and master2.1.

@rtrepos rtrepos closed this Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants