Created
February 5, 2015 13:00
-
-
Save sammachin/6c2b91d52b1052b0ec58 to your computer and use it in GitHub Desktop.
Convert 32bit binary int from BE to LE to Dec.
This file contains hidden or 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
| import struct | |
| def convert(input): | |
| v1 = struct.pack('>I', int(input, 2)) | |
| v2 = struct.unpack('<I', v1) | |
| output = int(''.join(map(str,v2))) | |
| return output | |
| convert('01000000010000100000111100000000') # returns 1000000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment