]> granicus.if.org Git - python/commitdiff
Describe new ("unsigned") behavior of hex() and oct().
authorGuido van Rossum <guido@python.org>
Tue, 14 Jan 1997 18:44:23 +0000 (18:44 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 14 Jan 1997 18:44:23 +0000 (18:44 +0000)
Doc/lib/libfuncs.tex
Doc/libfuncs.tex

index 9e7d4c1af6ee986013142373c8af64b82f9131c7..ddb3a9197ff8a74b57537a3bdeab08d85d8e4a06 100644 (file)
@@ -189,7 +189,12 @@ module from which it is called).
 
 \begin{funcdesc}{hex}{x}
   Convert an integer number (of any size) to a hexadecimal string.
-  The result is a valid Python expression.
+  The result is a valid Python expression.  Note: this always yields
+  an unsigned literal, e.g. on a 32-bit machine, \code{hex(-1)} yields
+  \code{'0xffffffff'}.  When evaluated on a machine with the same
+  word size, this literal is evaluated as -1; at a different word
+  size, it may turn up as a large positive number or raise an
+  \code{OverflowError} exception.
 \end{funcdesc}
 
 \begin{funcdesc}{id}{object}
@@ -256,7 +261,12 @@ any kind of sequence; the result is always a list.
 
 \begin{funcdesc}{oct}{x}
   Convert an integer number (of any size) to an octal string.  The
-  result is a valid Python expression.
+  result is a valid Python expression.  Note: this always yields
+  an unsigned literal, e.g. on a 32-bit machine, \code{oct(-1)} yields
+  \code{'037777777777'}.  When evaluated on a machine with the same
+  word size, this literal is evaluated as -1; at a different word
+  size, it may turn up as a large positive number or raise an
+  \code{OverflowError} exception.
 \end{funcdesc}
 
 \begin{funcdesc}{open}{filename\optional{\, mode\optional{\, bufsize}}}
index 9e7d4c1af6ee986013142373c8af64b82f9131c7..ddb3a9197ff8a74b57537a3bdeab08d85d8e4a06 100644 (file)
@@ -189,7 +189,12 @@ module from which it is called).
 
 \begin{funcdesc}{hex}{x}
   Convert an integer number (of any size) to a hexadecimal string.
-  The result is a valid Python expression.
+  The result is a valid Python expression.  Note: this always yields
+  an unsigned literal, e.g. on a 32-bit machine, \code{hex(-1)} yields
+  \code{'0xffffffff'}.  When evaluated on a machine with the same
+  word size, this literal is evaluated as -1; at a different word
+  size, it may turn up as a large positive number or raise an
+  \code{OverflowError} exception.
 \end{funcdesc}
 
 \begin{funcdesc}{id}{object}
@@ -256,7 +261,12 @@ any kind of sequence; the result is always a list.
 
 \begin{funcdesc}{oct}{x}
   Convert an integer number (of any size) to an octal string.  The
-  result is a valid Python expression.
+  result is a valid Python expression.  Note: this always yields
+  an unsigned literal, e.g. on a 32-bit machine, \code{oct(-1)} yields
+  \code{'037777777777'}.  When evaluated on a machine with the same
+  word size, this literal is evaluated as -1; at a different word
+  size, it may turn up as a large positive number or raise an
+  \code{OverflowError} exception.
 \end{funcdesc}
 
 \begin{funcdesc}{open}{filename\optional{\, mode\optional{\, bufsize}}}