fix(libc): return +0 from strtod when nothing is converted #3613
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3613"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by karim200003 on 2026-10-11T14:15:12Z.
The guest strtod, strtof, strtold, atof and the wide variants passed straight through to the host. When a sign is not followed by a number ("-", "-.", "-x", "-.e1", "-e5") nothing is consumed and the Windows runtime returns -0.0. FreeBSD's gdtoa strtod and strtodg clear the sign on their ret0 path and return +0.0 with the end pointer at the input; glibc already does the same.
The narrow functions now return +0 whenever the host consumed nothing, detected from their own end pointer so a null endptr works too, and leave every real conversion alone, so "-0", "-.0", "-0e5" and "-0x0p0" keep their sign. The wide functions parse through the narrow ones, and atof is strtod(str, NULL) as in FreeBSD.
guest_math and guest_wide_strings check the no-conversion shapes for all six functions, with and without endptr, and the -0 conversions that must stay negative.
Fixes #3090
AI-assisted: yes
What
Tested
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-11T14:15:23Z.
Thank you for your contribution! Authors with no pull requests merged into
maincan have 1 open pull request at a time, authors with at least 1 merged can have 20, and from 20 merged there is no limit. This PR has been automatically closed and labeled "open PR limit" because that limit was reached. This is not a judgment of the quality of your changes: reopen it once one of your open pull requests is merged or closed.Pull request closed