Skip to content

Instantly share code, notes, and snippets.

@Tolsi
Created February 21, 2020 16:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tolsi/fbd683bc14fbc7b9a1e351bb26786c48 to your computer and use it in GitHub Desktop.
Save Tolsi/fbd683bc14fbc7b9a1e351bb26786c48 to your computer and use it in GitHub Desktop.
handy ctypes examples
from ctypes import c_uint, c_int
print(c_uint(c_int(-49).value).value)
print(hex(c_uint(c_int(-49).value).value))
print(c_int(c_uint(0x7fffffcf).value).value)
print(hex(c_int(c_uint(0x7fffffcf).value).value))
# 4294967247
# 0xffffffcfL
# 2147483599
# 0x7fffffcf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment