-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
Fixed Issue #186 - add strto(f|d|ld) overload wrappers, "-0.0" special case and FP trailing zero #191
Conversation
I see that the Travis builds still fail and there is some debug output. Could you please drop a note once this is ready to merge? |
Note that this PR is currently a work in progress. It passes all tests locally including using identical settings as used by Travis for both CLANG 3.7 and GCC 4.9 (as well as GCC 5.2.1) and, obviously, AppVeyor. The only test that fails under Travis is a new test for "1.00000000000000011102230246251565404236316680908203126" which is expected to parse to 1.00000000000000022 but instead parses to exactly 1. The DEBUG ONLY commit (f79d52b) results shows that it is only the least significant bit that differs. The interesting thing is that doing a simple local test using |
Debug dumps added to pull #193 reveal that the error is definitely coming from |
@nlohmann, the issue is now resolved and this is ready for merge. |
Fixed Issue #186 - add strto(f|d|ld) overload wrappers, "-0.0" special case and FP trailing zero
Thanks a lot!! |
This pull request contains the following changes that have been discussed in issues #186 and #187:
get_number()
now calls overload wrappers forstrtof()
,strtod()
andstrtold(), instead of calling
strtold()directly. This prevents the double rounding that causes errors in particular cases where
number_float_tis not a
long double` due to the cast that is then required.parse_internal()
now tests for the special case of-0.0
and ensures that such numbers are stored as a float as they cannot be accurately represented with integer types.dump()
now tests for floating point numbers that do not have a fractional component (e.g.1.0
,42.0
,-36.0
) and in this case uses astd::fixed
andstd:setprecision(1)
representation. This is necessary for certain round trip tests to pass successfully.