Last active
August 29, 2015 14:17
-
-
Save 4u9u5tsong/ea8c81532fbec69accce to your computer and use it in GitHub Desktop.
python bit manipulation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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