[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 177b9cb52e)

Co-authored-by: Simon A. Eugster <simon.eu@gmail.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
This commit is contained in:
Miss Islington (bot) 2024-02-19 08:57:00 +01:00 committed by GitHub
parent c69da47ac9
commit eb759952ee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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.