Created
November 27, 2016 03:35
-
-
Save jsantanders/bd8d74d7c1ed2a325c20c28d63ebc76e to your computer and use it in GitHub Desktop.
module 2 division, python implementation.
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
binCrcGen = [1, 0, 0, 1] | |
s=0b1101010010111 | |
binPayload = [int(d) for d in str(bin(s))[2:]] | |
while len(binCrcGen) <= len(binPayload) and binPayload: | |
if binPayload[0] == binCrcGen[0]: | |
del binPayload[0] | |
for j in range(len(binCrcGen)-1): | |
binPayload[j] ^= binCrcGen[j+1] | |
print(binPayload, "binPayload") | |
while binPayload and binPayload[0] == 0: | |
del binPayload[0] | |
print(binPayload, "binPayload") | |
str1 = ''.join(str(e) for e in binPayload) | |
ces = int(str1,2) | |
ct = format(ces, 'b').zfill(4) | |
print(ct) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment