-
Notifications
You must be signed in to change notification settings - Fork 1
/
dec.py
25 lines (21 loc) · 1.02 KB
/
dec.py
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
import pyperclip
import struct
import os
hexl = ["0", "1", "2", "3", "4", "5", '6', '7', '8', '9', 'a', 'A', 'b', 'B', 'c', 'C', 'd', 'D', 'e', 'E', 'f', 'F']
install_dir = os.path.dirname(os.path.abspath(__file__))
with open(os.path.join(install_dir, '#language.txt'), 'r', encoding="utf-8") as txt:
language = txt.read()
language = [''] + language.splitlines()
start = int(language[1].split(":")[5])
print(language[start] + '\n')
# Welcome ! this app is used to convert hexadecimal float values to decimal float
while True: # forever
nospace = ''
entry = input(language[start + 1]) # hex-float :
for letter in entry:
if letter in hexl:
nospace += letter
nospace = '0' * (8 - len(nospace)) + nospace[:8] # add zeros to always make the value length to 8
number = struct.unpack('!f', bytes.fromhex(nospace))[0]
print(f"{language[start + 2]}\n{number}\n\n") # copied to clipboard the value below
pyperclip.copy(number) # copy converted integer to clipboard