-
Notifications
You must be signed in to change notification settings - Fork 354
#471 serializers: ensure float precision #472
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
#471 serializers: ensure float precision #472
Conversation
|
floats are |
|
Argh, sorry, I tried to reproduce it yesterday but managed to check out the wrong branch m( I agree that one probably doesn't want it to serialise to that, although it of course is correct, just ugly, even for numbers this low (slightly adapted from cppreference). One can set the precision for the float types specifically rather than using long-double for all. This does improve the ugliness slightly: With 1.7 it still is The easiest fix for the failing test is using a safe float like Do you have a preference? |
I like this one, with a serialize test for each to set expectations. |
Done. The test has the boilerplate to use the specific serializers as well, but commented out since it requires the dependencies, and I didn't want to add all the "if dependency is found" infrastructure which I don't see existing yet. I can offer to instead add it to some random respective connector-specific test? |
rbock
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update! This looks pretty thorough!
I added a couple of comments.
PTAL
I like this one best. Short. Sweet. Well documented for C++11. And yes, std::decay does a bit more than necessary, but nothing that would hurt. Co-authored-by: Bernd Lörwald <[email protected]>
|
Thanks for going the extra mile! Looks very good to me at this point. Please let me know if you are OK with merging at this point, too? |
Seems fine to me. 👍 I had some very-close-to-zero values deserialize badly in our unit tests, but that seems to be a SQLite issue, not an sqlpp one: Serializer is fine ⬆️ SQLite truncates. ⬇️ Appears that SQLite only guarantees 15 digits, for whatever reason. I think I'll change my tests to not assert bit-identical results ;) Edit: allowed for some inaccuracy, got 5000 successful test runs. |
|
Done, thanks!
👍 |
As described in #471, storing float values that need higher precision than the default
6would be rounded. This was true for all but postgresql prepared statements. Those were only supporting up todoubleand were off by a bit (maxdigits10vsdigits10).Now, all streams I could find (except those in prepared statements for specific non-float types) should be using full precision. An internal test that rolls random
doublevalues worked fine with various high random values.I'm not sure how to unit test this without having database backends, so a test is missing. Best I could come up with is serializing with some known-high-precision number and checking the string to be identical?