AIprojekt-wozek/venv/Lib/site-packages/pygame/tests/test_utils/endian.py

21 lines
495 B
Python
Raw Normal View History

2022-03-10 19:45:28 +01:00
# Module pygame.tests.test_utils.endian
#
# Machine independent conversion to little-endian and big-endian Python
# integer values.
import struct
def little_endian_uint32(i):
"""Return the 32 bit unsigned integer little-endian representation of i"""
s = struct.pack("<I", i)
return struct.unpack("=I", s)[0]
def big_endian_uint32(i):
"""Return the 32 bit unsigned integer big-endian representation of i"""
s = struct.pack(">I", i)
return struct.unpack("=I", s)[0]