Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit abba5c0

Browse files
committed
Explain that most floats are actually integers. This is a common confusion
for people using floor(), ceil() and modf().
1 parent 9a729a1 commit abba5c0

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

Doc/lib/libmath.tex

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,14 @@ \section{\module{math} ---
7979
second return value through an `output parameter' (there is no such
8080
thing in Python).
8181

82+
For the \function{ceil()}, \function{floor()}, and \function{modf()}
83+
functions, note that \emph{all} floating-point numbers of sufficiently
84+
large magnitude are exact integers. Python floats typically carry no more
85+
than 53 bits of precision (the same as the platform C double type), in
86+
which case any float \var{x} with \code{abs(\var{x}) >= 2**52}
87+
necessarily has no fractional bits.
88+
89+
8290
Power and logarithmic functions:
8391

8492
\begin{funcdesc}{exp}{x}

0 commit comments

Comments
 (0)