-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
executable file
·124 lines (106 loc) · 1.72 KB
/
Copy pathmain.py
File metadata and controls
executable file
·124 lines (106 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
print('Binary Translator\nCopyright (C) 2021 Peter Nielsen\nPlease see LICENSE.md for more details\n\n')
d15 = 0
d14 = 0
d13 = 0
d12 = 0
d11 = 0
d10 = 0
d9 = 0
d8 = 0
d7 = 0
d6 = 0
d5 = 0
d4 = 0
d3 = 0
d2 = 0
d1 = 0
d0 = 0
try:
user_input = int(input('Enter the number to translate (integers only, up to 65535)... '))
except:
print('You did not enter an integer. Setting input to 31415.')
user_input = 31415
if user_input - 32768 >= 0:
d15 += 1
user_input -= 32768
else:
pass
if user_input - 16384 >= 0:
d14 += 1
user_input -= 16384
else:
pass
if user_input - 8192 >= 0:
d13 += 1
user_input -= 8192
else:
pass
if user_input - 4096 >= 0:
d12 += 1
user_input -= 4096
else:
pass
if user_input - 2048 >= 0:
d11 += 1
user_input -= 2048
else:
pass
if user_input - 1024 >= 0:
d10 += 1
user_input -= 1024
else:
pass
if user_input - 512 >= 0:
d9 += 1
user_input -= 512
else:
pass
if user_input - 256 >= 0:
d8 += 1
user_input -= 256
else:
pass
if user_input - 128 >= 0:
d7 += 1
user_input -= 128
else:
pass
if user_input - 64 >= 0:
d6 += 1
user_input -= 64
else:
pass
if user_input - 32 >= 0:
d5 += 1
user_input -= 32
else:
pass
if user_input - 16 >= 0:
d4 += 1
user_input -= 16
else:
pass
if user_input - 8 >= 0:
d3 += 1
user_input -= 8
else:
pass
if user_input - 4 >= 0:
d2 += 1
user_input -= 4
else:
pass
if user_input - 2 >= 0:
d1 += 1
user_input -= 2
else:
pass
if user_input - 1 >= 0:
d0 += 1
user_input -= 1
else:
pass
if user_input == 0:
print(f'{d15}{d14}{d13}{d12}{d11}{d10}{d9}{d8}{d7}{d6}{d5}{d4}{d3}{d2}{d1}{d0}')
else:
print('Your number was larger than 65535.')