-
Notifications
You must be signed in to change notification settings - Fork 113
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
Fix issue in float serialization #1188
Conversation
This does not look right - 1.40129846e-45 gets serialized to {"value":1.E-45} which is ok (it is denormalized) but it cant be deserialized by glaze. following the railroad diagram at https://www.json.org/json-en.html, it seems like the dot must be followed by a digit. |
Thanks for pointing this out. Fixed in #1190 |
By the way I noticed that you are calling I'm expecting that maybe the performance gain you can obtain by calling I would appreciate it if you can investigate the possibility of replacing your call to If you're interested, these two are the points relevant to usage of https://github.com/jk-jeon/dragonbox/blob/master/include/dragonbox/dragonbox_to_chars.h#L220 |
@jk-jeon, Thanks so much for pointing this out. I just implemented this change here: #1316. But, I'm doing something wrong. One of the complications of this interface is the compile time policies. It is critical for these policies to be compile time (for performance), but you have a lot of code that complicates your library for handling these policies and it makes your code harder to read and work with. Your approach is also more compile time intensive than it needs to be. Since C++ now supports non-type template parameters, a much cleaner and faster to compile solution is to pass a struct of policies (e.g. options). Glaze uses this approach with great success. Here's a simple example: struct policies
{
bool option_one{};
bool option_two{};
};
template <policies Policies = policies{}>
void func()
{
}
// Now a user can call this function via:
func<policies{.option_two = true}>();
// or, they can even make a struct of policies to pass around:
static constexpr policies policy{.option_two = true};
func<policies>(); |
This merge uses dragonbox underneath to ensure proper serialization of floats.