Skip to content

Fix for printing long doubles bug in dump_float#3929

Merged
nlohmann merged 13 commits into
nlohmann:developfrom
RUSLoker:patch-1
May 15, 2026
Merged

Fix for printing long doubles bug in dump_float#3929
nlohmann merged 13 commits into
nlohmann:developfrom
RUSLoker:patch-1

Conversation

@RUSLoker
Copy link
Copy Markdown
Contributor

@RUSLoker RUSLoker commented Jan 25, 2023

When you use long double as a floating point type with the current version of include/nlohmann/detail/output/serializer.hpp and try to dump json it prints trash instead of actual number. This if-else fixes the problem. On using long double you just need to add an 'L' modifier before 'g' in format string.

When you use long double as a floating point type with the current version of this file and try to dump json it prints trash instead of actual number. This if-else fixes the problem. On using long double you just need to add an 'L' modifier before 'g' in format string.

Signed-off-by: Kirill Lokotkov <klokotkov@ya.ru>
@RUSLoker RUSLoker requested a review from nlohmann as a code owner January 25, 2023 15:35
@github-actions
Copy link
Copy Markdown

🔴 Amalgamation check failed! 🔴

The source code has not been amalgamated. @RUSLoker Please read and follow the Contribution Guidelines.

@github-actions github-actions Bot added the S label Jan 25, 2023
Copy link
Copy Markdown
Owner

@nlohmann nlohmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The library targets C++11. Please adjust the code.

Signed-off-by: Kirill Lokotkov <klokotkov@ya.ru>
@RUSLoker RUSLoker requested a review from nlohmann January 25, 2023 15:46
Comment thread include/nlohmann/detail/output/serializer.hpp Outdated
@github-actions
Copy link
Copy Markdown

🔴 Amalgamation check failed! 🔴

The source code has not been amalgamated. @RUSLoker Please read and follow the Contribution Guidelines.

Signed-off-by: Kirill Lokotkov <klokotkov@ya.ru>
@github-actions
Copy link
Copy Markdown

🔴 Amalgamation check failed! 🔴

The source code has not been amalgamated. @RUSLoker Please read and follow the Contribution Guidelines.

Signed-off-by: rusloker <klokotkov@ya.ru>
@RUSLoker RUSLoker requested review from gregmarr and nlohmann and removed request for gregmarr and nlohmann January 26, 2023 08:46
@coveralls
Copy link
Copy Markdown

coveralls commented Jan 26, 2023

Coverage Status

coverage: 100.0%. remained the same
when pulling cf5c7fb on RUSLoker:patch-1
into a259ecc on nlohmann:develop.

Copy link
Copy Markdown
Contributor

@gregmarr gregmarr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, @nlohmann will need to merge.

@t-b
Copy link
Copy Markdown
Contributor

t-b commented Jan 26, 2023

I think a test is missing or?

@nlohmann
Copy link
Copy Markdown
Owner

Yes, a test is definitely required.

There is also #3906 that I need to take care of to finally have a green CI again. I'm busy right now, so sorry for delays.

@nlohmann
Copy link
Copy Markdown
Owner

Please update to recent develop version - the CI is fixed there (see #3906).

@nlohmann nlohmann added the please rebase Please rebase your branch to origin/develop label Jan 31, 2023
@RUSLoker
Copy link
Copy Markdown
Contributor Author

RUSLoker commented Feb 1, 2023

@nlohmann, it asks for your approval to run CI workflows.

@RUSLoker
Copy link
Copy Markdown
Contributor Author

RUSLoker commented Feb 1, 2023

@nlohmann, @gregmarr, what's wrong with Cirrus CI / check?

@nlohmann
Copy link
Copy Markdown
Owner

nlohmann commented Feb 1, 2023

@nlohmann, @gregmarr, what's wrong with Cirrus CI / check?

Looks like a glitch.

@nlohmann nlohmann removed the please rebase Please rebase your branch to origin/develop label Feb 1, 2023
Copy link
Copy Markdown
Owner

@nlohmann nlohmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add tests.

@github-actions github-actions Bot removed the S label Dec 15, 2023
@RUSLoker RUSLoker requested a review from nlohmann May 14, 2026 10:59
@github-actions github-actions Bot added M tests and removed S labels May 14, 2026
@nlohmann
Copy link
Copy Markdown
Owner

I think this can be closed in favor of #5169.

@RUSLoker
Copy link
Copy Markdown
Contributor Author

@nlohmann, I haven't found any tests in #5169. Maybe you should take mine?

@nlohmann
Copy link
Copy Markdown
Owner

Sounds good, so please update to the latest develop branch.

# Conflicts:
#	include/nlohmann/detail/output/serializer.hpp
#	single_include/nlohmann/json.hpp
Comment thread tests/src/unit-serialization.cpp Outdated
Signed-off-by: rusloker <klokotkov@ya.ru>
@RUSLoker
Copy link
Copy Markdown
Contributor Author

@nlohmann, added fix to your solution. Reason described in the code comment.

Comment thread include/nlohmann/detail/output/serializer.hpp
Comment thread include/nlohmann/detail/output/serializer.hpp Outdated
Comment thread tests/src/unit-serialization.cpp Outdated
…type safety

Signed-off-by: rusloker <klokotkov@ya.ru>
@RUSLoker RUSLoker requested a review from nlohmann May 15, 2026 08:31
Comment thread tests/src/unit-serialization.cpp Outdated
@RUSLoker RUSLoker requested a review from nlohmann May 15, 2026 12:02
Signed-off-by: rusloker <klokotkov@ya.ru>
@nlohmann
Copy link
Copy Markdown
Owner

Please check the DCO requirements.

@RUSLoker RUSLoker force-pushed the patch-1 branch 2 times, most recently from 30dd3ba to ecafc47 Compare May 15, 2026 13:49
@nlohmann nlohmann removed the please rebase Please rebase your branch to origin/develop label May 15, 2026
Copy link
Copy Markdown
Owner

@nlohmann nlohmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@nlohmann nlohmann added this to the Release 3.12.1 milestone May 15, 2026
@RUSLoker RUSLoker requested a review from gregmarr May 15, 2026 15:06
@RUSLoker
Copy link
Copy Markdown
Contributor Author

Yeeeeah, finally my fix would be merged after 3 years :) Danke!

@nlohmann nlohmann merged commit b1bb9fc into nlohmann:develop May 15, 2026
140 of 143 checks passed
@nlohmann
Copy link
Copy Markdown
Owner

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants