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

sdp::grammar::number_converter precision #210

Closed
garethsb opened this issue Nov 9, 2021 · 0 comments · Fixed by #244
Closed

sdp::grammar::number_converter precision #210

garethsb opened this issue Nov 9, 2021 · 0 comments · Fixed by #244

Comments

@garethsb
Copy link
Contributor

garethsb commented Nov 9, 2021

The sdp::grammar::number_converter currently uses sufficient precision to guarantee roundtrip of all double values (by virtue of using the web::json::value::serialize() function, with the particular effect that a number like 59.94 is serialized as 59.939999999999998. Good for test cases, but probably not much else. See microsoft/cpprestsdk#706.

A custom attribute converter can be used to work around this issue, though the workaround ends up a little more verbose than one would like.

Some way of globally (within one make_session_description call) specifying precision or the number format in general was previously considered and rejected.

Another option may be to follow the resolution taken for nlohmann/json#360 and adopt the Grisu2 algorithm from Florian Loitsch. Since nmos-cpp already has nlohmann/json as a dependency, its implementation could be used.

@garethsb garethsb mentioned this issue Feb 7, 2022
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 a pull request may close this issue.

1 participant