Skip to content

Instantly share code, notes, and snippets.

@edenizk
Created May 11, 2018 17:07
Show Gist options
  • Select an option

  • Save edenizk/7f656fe211f29d91868dffbe560c8f9b to your computer and use it in GitHub Desktop.

Select an option

Save edenizk/7f656fe211f29d91868dffbe560c8f9b to your computer and use it in GitHub Desktop.
checks decimal lenght
x = int(eval(input("x = ") ) )
k = int(input("k = "))
print(k , "position digit = ", (abs(x) // 10 ** k) % 10)
print(k , "position digit = ", (abs(x) // 10 ** k) % 2)
print ("length of the decimal number = ", len(str(x)))
print ("length of the binary number = ", len(str(bin(abs(x))))-2, )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment