mirror of
https://github.com/nlohmann/json.git
synced 2026-10-10 16:37:14 +00:00
Write doubles from their bits only where double is IEEE 754 binary64
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
2 files changed
+8
-4
No files matched your search
@@ -257,6 +257,8 @@ class view_serializer
|
||||
using nav = navigation<Editable>;
|
||||
using string_t = typename BasicJsonType::string_t;
|
||||
using number_float_t = typename BasicJsonType::number_float_t;
|
||||
/// doubles that are IEEE 754 binary64 are written from their bits (Zmij)
|
||||
using fast_double = std::integral_constant < bool, std::is_same<number_float_t, double>::value && ::nlohmann::detail::dtoa_impl::is_binary64<double>::value >;
|
||||
|
||||
public:
|
||||
view_serializer(const document_data& d, string_t& out, std::size_t estimate, const dump_style& style)
|
||||
@@ -526,7 +528,7 @@ class view_serializer
|
||||
room(n->len);
|
||||
copy(src + n->off, n->len);
|
||||
}
|
||||
else if (enabled(std::is_same<number_float_t, double>::value))
|
||||
else if (enabled(fast_double::value))
|
||||
{
|
||||
room(64);
|
||||
w = write_double_at(w, *n);
|
||||
@@ -716,7 +718,7 @@ class view_serializer
|
||||
/// a float node as dump() writes it
|
||||
void write_float_node(const node& n)
|
||||
{
|
||||
write_float_node(n, std::is_same<number_float_t, double> {});
|
||||
write_float_node(n, fast_double {});
|
||||
}
|
||||
|
||||
void write_float_node(const node& n, std::false_type /*other*/)
|
||||
|
||||
Reference in new issue
Block a user