Skip to content

Instantly share code, notes, and snippets.

@4u9u5tsong
Last active August 29, 2015 14:17
Show Gist options
  • Save 4u9u5tsong/ea8c81532fbec69accce to your computer and use it in GitHub Desktop.
Save 4u9u5tsong/ea8c81532fbec69accce to your computer and use it in GitHub Desktop.
python bit manipulation
def float64Tobinary(num):
return ''.join(bin(ord(c)).replace('0b', '').rjust(8, '0') for c in
struct.pack('!d', num))
def convertTo1DIntArray(d, start, end, patternwidth, f):
sview = 'S' + str(patternwidth)
return f(d[start:end]).view(sview)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment