Skip to content

Commit e0a173d

Browse files
bpo-45584: Clarify the meaning of truncate in documentation
While floor/ceil 's documentation are very precise, `truncate` was not explained. I actually had to search online to understand the difference between `truncate` and `floor` (admittedly, once I remembered that numbers are signed, and that floating numbers actually uses a bit for negation symbol instead of two complement, it became obvious) I assume that I won't be the only user having this trouble, especially for people whose mother tongue is not English. So I suggest adding a clarification to help make what should be obvious to most actually explicit
1 parent 074fa57 commit e0a173d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Doc/library/math.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,10 @@ Number-theoretic and representation functions
299299
.. function:: trunc(x)
300300

301301
Return the :class:`~numbers.Real` value *x* truncated to an
302-
:class:`~numbers.Integral` (usually an integer). Delegates to
303-
:meth:`x.__trunc__() <object.__trunc__>`.
302+
:class:`~numbers.Integral` (usually an integer). Truncating *x* means
303+
removing the digits after the decimal separator, hence rounding toward 0. It
304+
is equivalent to floor and ceil for positive and negative numbers
305+
respectively. Delegates to :meth:`x.__trunc__() <object.__trunc__>`.
304306

305307
.. function:: ulp(x)
306308

0 commit comments

Comments
 (0)