Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import struct
- getBin = lambda x: x > 0 and str(bin(x))[2:] or "-" + str(bin(x))[3:]
- def floattoBinary64t(value):
- val = struct.unpack('Q', struct.pack('d', value))[0]
- return getBin(val)
- print('Program obliczający wartość liczby zmiennoprzecinkowej w standardzie IEEE754\n')
- numb = float(input('Podaj liczbę : '))
- # liczba zmiennoprzecinkowa na liczbę binarną
- binstr = floattoBinary64t(numb)
- print("Binarna wartość liczby "), numb
- print(binstr + '\n')
- print('Wykonał Grzegorz Paradowski Z506')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement