https://github.com/python/cpython/commit/eb759952eecdf2ffacb2ea31767e5084352d5b5d
commit: eb759952eecdf2ffacb2ea31767e5084352d5b5d
branch: 3.11
author: Miss Islington (bot) <[email protected]>
committer: hauntsaninja <[email protected]>
date: 2024-02-19T07:57:00Z
summary:

[3.11] Docs: Add explanation about little/big endian (GH-109841) (#115647)

Docs: Add explanation about little/big endian (GH-109841)
(cherry picked from commit 177b9cb52e57da4e62dd8483bcd5905990d03f9e)

Co-authored-by: Simon A. Eugster <[email protected]>
Co-authored-by: Adam Turner <[email protected]>
Co-authored-by: Shantanu <[email protected]>

files:
M Doc/library/struct.rst

diff --git a/Doc/library/struct.rst b/Doc/library/struct.rst
index 416b01db615fa0..54d717c5397933 100644
--- a/Doc/library/struct.rst
+++ b/Doc/library/struct.rst
@@ -156,6 +156,21 @@ following table:
 
 If the first character is not one of these, ``'@'`` is assumed.
 
+.. note::
+
+   The number 1023 (``0x3ff`` in hexadecimal) has the following byte 
representations:
+
+   * ``03 ff`` in big-endian (``>``)
+   * ``ff 03`` in little-endian (``<``)
+
+   Python example:
+
+       >>> import struct
+       >>> struct.pack('>h', 1023)
+       b'\x03\xff'
+       >>> struct.pack('<h', 1023)
+       b'\xff\x03'
+
 Native byte order is big-endian or little-endian, depending on the
 host system. For example, Intel x86, AMD64 (x86-64), and Apple M1 are
 little-endian; IBM z and many legacy architectures are big-endian.

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to