summaryrefslogtreecommitdiffstats
path: root/Doc/ref
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>1999-05-06 14:46:35 (GMT)
committerFred Drake <fdrake@acm.org>1999-05-06 14:46:35 (GMT)
commit1ea7c7568769e156164ed4c860e3778f844fe502 (patch)
tree375f88fc0939b840cea76c51b80ed0af12e2b701 /Doc/ref
parent9263e78ff22a5aaa0c2b460df966e048dd28f90d (diff)
downloadcpython-1ea7c7568769e156164ed4c860e3778f844fe502.zip
cpython-1ea7c7568769e156164ed4c860e3778f844fe502.tar.gz
cpython-1ea7c7568769e156164ed4c860e3778f844fe502.tar.bz2
Reflect recent patch for float % and divmod() by Tim Peters. Content
updates by Tim Peters, markup by FLD.
Diffstat (limited to 'Doc/ref')
-rw-r--r--Doc/ref/ref5.tex13
1 files changed, 10 insertions, 3 deletions
diff --git a/Doc/ref/ref5.tex b/Doc/ref/ref5.tex
index 77496fe..72a2053 100644
--- a/Doc/ref/ref5.tex
+++ b/Doc/ref/ref5.tex
@@ -583,9 +583,16 @@ The integer division and modulo operators are connected by the
following identity: \code{x == (x/y)*y + (x\%y)}. Integer division and
modulo are also connected with the built-in function \function{divmod()}:
\code{divmod(x, y) == (x/y, x\%y)}. These identities don't hold for
-floating point and complex numbers; there a similar identity holds where
-\code{x/y} is replaced by \code{floor(x/y)}) or
-\code{floor((x/y).real)}, respectively.
+floating point and complex numbers; there similar identities hold
+approximately where \code{x/y} is replaced by \code{floor(x/y)}) or
+\code{floor(x/y) - 1} (for floats),\footnote{
+ If x is very close to an exact integer multiple of y, it's
+ possible for \code{floor(x/y)} to be one larger than
+ \code{(x-x\%y)/y} due to rounding. In such cases, Python returns
+ the latter result, in order to preserve that \code{divmod(x,y)[0]
+ * y + x \%{} y} be very close to \code{x}.
+} or \code{floor((x/y).real)} (for
+complex).
The \code{+} (addition) operator yields the sum of its arguments.
The arguments must either both be numbers or both sequences of the