summaryrefslogtreecommitdiffstats
path: root/Doc/lib/libstruct.tex
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-01-03 04:20:09 (GMT)
committerGuido van Rossum <guido@python.org>1997-01-03 04:20:09 (GMT)
commitdbadd558b5de96ecff74218d44e15515a635b785 (patch)
tree2468bd76864584ac04b606cba4b65bac680dfa3f /Doc/lib/libstruct.tex
parentb9a781e177ace3ef32fa40a98f0792432ec9fdd3 (diff)
downloadcpython-dbadd558b5de96ecff74218d44e15515a635b785.zip
cpython-dbadd558b5de96ecff74218d44e15515a635b785.tar.gz
cpython-dbadd558b5de96ecff74218d44e15515a635b785.tar.bz2
Describe standard float/double support.
Rewrite example to be an interactive session
Diffstat (limited to 'Doc/lib/libstruct.tex')
-rw-r--r--Doc/lib/libstruct.tex16
1 files changed, 10 insertions, 6 deletions
diff --git a/Doc/lib/libstruct.tex b/Doc/lib/libstruct.tex
index f29d83c..6431ca5 100644
--- a/Doc/lib/libstruct.tex
+++ b/Doc/lib/libstruct.tex
@@ -101,8 +101,8 @@ expression. This is always combined with native byte order.
Standard size and alignment are as follows: no alignment is required
for any type (so you have to use pad bytes); short is 2 bytes; int and
-long are 4 bytes. In this mode, there is no support for float and
-double (\code{'f'} and \code{'d'}).
+long are 4 bytes. Float and double are 32-bit and 64-bit IEEE floating
+point numbers, respectively.
Note the difference between \code{'@'} and \code{'='}: both use native
byte order, but the size and alignment of the latter is standardized.
@@ -119,10 +119,14 @@ Examples (all using native byte order, size and alignment, on a
big-endian machine):
\bcode\begin{verbatim}
-from struct import *
-pack('hhl', 1, 2, 3) == '\000\001\000\002\000\000\000\003'
-unpack('hhl', '\000\001\000\002\000\000\000\003') == (1, 2, 3)
-calcsize('hhl') == 8
+>>> from struct import *
+>>> pack('hhl', 1, 2, 3)
+'\000\001\000\002\000\000\000\003'
+>>> unpack('hhl', '\000\001\000\002\000\000\000\003')
+(1, 2, 3)
+>>> calcsize('hhl')
+8
+>>>
\end{verbatim}\ecode
Hint: to align the end of a structure to the alignment requirement of