Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- firstbin = 0b1110
- secondbin = 0b101
- strfirstbin = str(bin(firstbin))
- strsecondbin = str(bin(secondbin))
- fbin2 = strfirstbin[2::]
- sbin2 = strsecondbin[2::]
- lenf = len(fbin2)
- lens = len(sbin2)
- result = []
- if lenf == lens:
- for i in fbin2:
- if i == "1":
- for d in sbin2:
- if i == d:
- result.append("1")
- else:
- result.append("0")
- else:
- result.append("0")
- else:
- if lenf > lens:
- substr = lenf - lens
- fbin3 = fbin2[int(substr)::]
- for i in fbin3:
- if i == "1":
- for d in sbin2:
- if d == i:
- result.append("1")
- else:
- result.append("0")
- else:
- result.append("0")
- elif lens > lenf:
- substr = lens - lenf
- sbin3 = sbin2[int(substr)::]
- for i in fbin2:
- if i == "1":
- for d in sbin3:
- if d == i:
- result.append("1")
- else:
- result.append("0")
- else:
- result.append("0")
- print "".join(result)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement