From 6aa10fd3432c6ec01dfc8503023b2f7a9ac93c2f Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Mon, 2 Nov 2026 17:25:51 +0100 Subject: [PATCH] Simplify the decimal point condition in dump_float Signed-off-by: Niels Lohmann --- include/nlohmann/detail/output/serializer.hpp | 2 +- single_include/nlohmann/json.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/nlohmann/detail/output/serializer.hpp b/include/nlohmann/detail/output/serializer.hpp index 33501dfc5..ad8f8801f 100644 --- a/include/nlohmann/detail/output/serializer.hpp +++ b/include/nlohmann/detail/output/serializer.hpp @@ -2106,7 +2106,7 @@ class serializer const std::size_t decimal_point_len = std::char_traits::length(decimal_point); // convert decimal point to '.' - if (decimal_point_len != 0 && !(decimal_point_len == 1 && decimal_point[0] == '.')) + if ((decimal_point_len > 1) || (decimal_point_len == 1 && decimal_point[0] != '.')) { const auto first = number_buffer.begin(); const auto last = first + len; diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 23f6f616d..fd8b70e6f 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -37353,7 +37353,7 @@ class serializer const std::size_t decimal_point_len = std::char_traits::length(decimal_point); // convert decimal point to '.' - if (decimal_point_len != 0 && !(decimal_point_len == 1 && decimal_point[0] == '.')) + if ((decimal_point_len > 1) || (decimal_point_len == 1 && decimal_point[0] != '.')) { const auto first = number_buffer.begin(); const auto last = first + len;