Skip to content
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

[3.13] gh-99880: document rounding mode for new-style formatting (GH-121481) #126334

Merged
merged 1 commit into from
Dec 2, 2024

Conversation

miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Nov 2, 2024

The CPython uses _Py_dg_dtoa(), which does rounding to nearest with half
to even tie-breaking rule.

If that functions is unavailable, PyOS_double_to_string() fallbacks to
system snprintf(). Since CPython 3.12, build requirements include C11
compiler and support for IEEE 754 floating point numbers (Annex F).
This means that FE_TONEAREST macro is available and, per default,
printf-like functions should use same rounding mode as _Py_dg_dtoa().

  • Update Doc/library/string.rst

Co-authored-by: Bénédikt Tran 10796600+picnixz@users.noreply.github.com


(cherry picked from commit 7d7d56d)

Co-authored-by: Sergey B Kirpichev skirpichev@gmail.com
Co-authored-by: Bénédikt Tran 10796600+picnixz@users.noreply.github.com


📚 Documentation preview 📚: https://cpython-previews--126334.org.readthedocs.build/

…onGH-121481)

* pythongh-99880: document rounding mode for new-style formatting

The CPython uses _Py_dg_dtoa(), which does rounding to nearest with half
to even tie-breaking rule.

If that functions is unavailable, PyOS_double_to_string() fallbacks to
system snprintf().  Since CPython 3.12, build requirements include C11
compiler *and* support for IEEE 754 floating point numbers (Annex F).
This means that FE_TONEAREST macro is available and, per default,
printf-like functions should use same rounding mode as _Py_dg_dtoa().

* Update Doc/library/string.rst

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>

---------

(cherry picked from commit 7d7d56d)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
@bedevere-app bedevere-app bot added docs Documentation in the Doc dir skip news awaiting review labels Nov 2, 2024
@Yhg1s Yhg1s merged commit 23ab1f9 into python:3.13 Dec 2, 2024
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir skip news
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants