Created
February 12, 2018 07:25
-
-
Save srakrn/dc7d72e5c6d3e893a89f78d34d35c3e2 to your computer and use it in GitHub Desktop.
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 to_signed_bit(x): | |
return format(x & 0xff, '08b') | |
f = open('all_inputs_sra_test.txt', 'w') | |
f.write('A[8] shft[3] out[8]\n') | |
a_values = range(-128, 128) | |
shft_values = range(0, 8) | |
for a in a_values: | |
for shft in shft_values: | |
out = a >> shft | |
print("{} {}".format(a, to_signed_bit(a))) | |
f.write("{} {} {}\n".format(to_signed_bit(a), shft, to_signed_bit(out))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment