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

Skip to content

Commit 78fc0b5

Browse files
committed
Fixed legit gripe from c.l.py that math.fmod docs aren't confusing enough.
FRED, please check my monkey-see-monkey-do Tex fiddling!
1 parent 53db815 commit 78fc0b5

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

Doc/lib/libmath.tex

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ \section{\module{math} ---
6060
\end{funcdesc}
6161

6262
\begin{funcdesc}{fmod}{x, y}
63-
Return \code{\var{x} \%\ \var{y}}.
63+
Return \code{fmod(\var{x}, \var{y})}, as defined by the platform C library.
64+
Note that the Python expression \code{\var{x} \%\ \var{y}} may not return
65+
the same result.
6466
\end{funcdesc}
6567

6668
\begin{funcdesc}{frexp}{x}

Modules/mathmodule.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ FUNC1(fabs, fabs,
106106
FUNC1(floor, floor,
107107
"floor(x)\n\nReturn the floor of x as a real.")
108108
FUNC2(fmod, fmod,
109-
"fmod(x,y)\n\nReturn x % y.")
109+
"fmod(x,y)\n\nReturn fmod(x, y), according to platform C."
110+
" x % y may differ.")
110111
FUNC2(hypot, hypot,
111112
"hypot(x,y)\n\nReturn the Euclidean distance, sqrt(x*x + y*y).")
112113
FUNC1(log, log,

Objects/floatobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ float_divmod(PyFloatObject *v, PyFloatObject *w)
399399
PyFPE_START_PROTECT("divmod", return 0)
400400
vx = v->ob_fval;
401401
mod = fmod(vx, wx);
402-
/* fmod is typically exact, so vx-mod is *mathemtically* an
402+
/* fmod is typically exact, so vx-mod is *mathematically* an
403403
exact multiple of wx. But this is fp arithmetic, and fp
404404
vx - mod is an approximation; the result is that div may
405405
not be an exact integral value after the division, although

0 commit comments

Comments
 (0)