-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
msgpack serialisation : float is treated as 64bit float, not 32bit float. #2196
Comments
For CBOR, you apply range checking like so
So if your float is in a 32bit float range, cast it to a 32bit float. You don't do that in the msgpack serialiser. Maybe it could? Or, in :
we separate the number_float enum into 2 separate enums. Options... |
Interestingly, i wanted to see if the CBOR serialisation was slower due to bounds checking, and it isn't, it's nearly 3x faster. I used the following code:
Which outputs
So maybe adding bounds checking isn't going to affect performance... |
We only recently added the code to the CBOR serializer to use 32-bit floats where possible. Not using the same approach in MessagePack was an oversight. I think adding this should be possible. |
@pfeatherstone Could you please try with 88a3701 whether everything works as expected? In your initial example, I got the output |
Yep all works fine. Thanks for the quick fix |
I still need to adjust the test suites, as the change affects existing tests. But then this should be ready for the next release. |
marvelous. So do you intend on postponing the release until you have a large enough set of new features, or will you do a quick minor release? |
I would also add the solution proposed by @KonanM in issue 2175 to the next release as it looks oven baked to me. |
I'm not sure about the release cycle. My usual approach is to wait until it feels "done". There are several issues that are nearly ready, so I will not rush anything because of this issue. |
Cool |
* ⬆️ Doctest 2.4.7 * 👷 add CI step for ICPC * 👷 add CI step for ICPC * 👷 add CI step for ICPC * ⬇️ downgrade to Doctest 2.4.6 * 👷 add CI step for ICPC * 👷 add CI step for ICPC * 👷 add CI step for ICPC * 👷 add CI step for ICPC * 👷 add CI step for ICPC * 🔇 suppress warning #2196: routine is both "inline" and "noinline" * Re-enable <filesystem> detection on ICPC * Limit regression test for #3070 to Clang and GCC >=8.4 * Disable deprecation warnings on ICPC * Disable regression test for #1647 on ICPC (C++20) * Fix compilation failure of regression test for #3077 on ICPC * Disable wstring unit test on ICPC Fixes: error 913: invalid multibyte character sequence * Add ICPC to README Co-authored-by: Niels Lohmann <mail@nlohmann.me>
Example:
I would expect this to print roughly ~ 5000, instead it is printing ~ 9000.
Going through GDB, it is treating the float type as 64bit.
The text was updated successfully, but these errors were encountered: