Skip to content

return zero from dec_to_float when the mantissa is zero - #1202

Open
Ramya-9353 wants to merge 1 commit into
boostorg:developfrom
Ramya-9353:parser-zero-mantissa-nan
Open

Ramya-9353 wants to merge 1 commit into
boostorg:developfrom
Ramya-9353:parser-zero-mantissa-nan

Conversation

@Ramya-9353

Copy link
Copy Markdown
Contributor

Repro: parse("0e400") with default options returns a double that is NaN, and serialize of that value emits null, so the number changes JSON type on a round trip. 0e309, -0e400, 0.0e400 and 0E+400 behave the same. The same literals give 0 and -0 under number_precision::precise, and 1e400 gives infinity as intended.
Cause: dec_to_float scales the mantissa with x * pow10(e), and pow10 returns infinity for any exponent above 308. With a zero mantissa that product is 0 * inf, which is NaN.
Fix: return the already signed zero before the scaling when the mantissa is zero, so -0e400 gives -0.0 like the precise path. The two added grind_double cases fail on develop (13 assertions across the split points) and pass with the change.

@cppalliance-bot

cppalliance-bot commented Sep 30, 2026 •

Copy link
Copy Markdown

An automated preview of the documentation is available at https://1202.json.prtest2.cppalliance.org/libs/json/doc/html/index.html

If more commits are pushed to the pull request, the docs will rebuild at the same URL.

2026-10-08 11:03:07 UTC

@cppalliance-bot

cppalliance-bot commented Sep 30, 2026 •

Copy link
Copy Markdown

GCOVR code coverage report https://1202.json.prtest2.cppalliance.org/gcovr/index.html
LCOV code coverage report https://1202.json.prtest2.cppalliance.org/genhtml/index.html
Coverage Diff Report https://1202.json.prtest2.cppalliance.org/diff-report/index.html

Build time: 2026-10-08 11:30:55 UTC

@cppalliance-bot

Copy link
Copy Markdown

Comment thread include/boost/json/basic_parser_impl.hpp
@Ramya-9353
Ramya-9353 force-pushed the parser-zero-mantissa-nan branch from 916991c to 4dff941 Compare October 7, 2026 10:05
@cppalliance-bot

Copy link
Copy Markdown

@codecov

codecov Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.98%. Comparing base (fc70d23) to head (47fb530).
⚠️ Report is 3 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #1202   +/-   ##
========================================
  Coverage    93.98%   93.98%           
========================================
  Files           85       85           
  Lines         8973     8973           
========================================
  Hits          8433     8433           
  Misses         540      540           
Files with missing lines Coverage Δ
include/boost/json/basic_parser_impl.hpp 99.21% <100.00%> (+<0.01%) ⬆️

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fc70d23...47fb530. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Ramya-9353
Ramya-9353 force-pushed the parser-zero-mantissa-nan branch from 4dff941 to 47fb530 Compare October 8, 2026 10:57
@cppalliance-bot

Copy link
Copy Markdown

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants