Skip to content

Instantly share code, notes, and snippets.

@Dav1dde
Created May 11, 2012 18:01
Show Gist options
  • Save Dav1dde/2661382 to your computer and use it in GitHub Desktop.
Save Dav1dde/2661382 to your computer and use it in GitHub Desktop.
In [21]: res = 0
In [22]: for i, element in enumerate(x):
res |= element << i*4
....:
In [23]: res
Out[23]: 1048575
In [24]: hex(res)
Out[24]: '0xfffff'
In [25]: x
Out[25]: [15, 15, 15, 15, 15]
In [26]: [hex(e) for e in x]
Out[26]: ['0xf', '0xf', '0xf', '0xf', '0xf']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment