hi
this is my coding to convert HEX to Binary :
and the results I've got is 1101110110110101100 in binary, i would like to covert them into text in python,
like a text "1101110110110101100" so that i can assign each and give every single one of them a declaration like this
binary position 19 = 0.5
binary position 18 = 0.25 ... etc
in the end i want to do a simple check and add function :
if binary 19 = 1, binary 18 =1, 0.5 + 0.25 etc..
the results will be something like 0.0011.
anyone got an idea how to convert or assign each binary position a value?
appreciate your help here :)
this is my coding to convert HEX to Binary :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# conversion of hex string # to binary string import math # Initialising hex string ini_string = "6EDAC" # Printing initial string print ( "Initial string" , ini_string) # Code to convert hex to binary res = "{0:08b}" . format ( int (ini_string, 16 )) # Print the resultant string print ( "Resultant string" , str (res)) |
like a text "1101110110110101100" so that i can assign each and give every single one of them a declaration like this
binary position 19 = 0.5
binary position 18 = 0.25 ... etc
in the end i want to do a simple check and add function :
if binary 19 = 1, binary 18 =1, 0.5 + 0.25 etc..
the results will be something like 0.0011.
anyone got an idea how to convert or assign each binary position a value?
appreciate your help here :)
Larz60+ write Jul-16-2021, 04:37 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use bbcode tags on future posts.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use bbcode tags on future posts.