Post Reply 
Python: some practice, questions and #%§'
05-16-2021, 10:17 AM
Post: #5
RE: Python: some practice, questions and #%§'
Another trap:
in your snipped:
Quote: print('key= '+str(int(log2(k))))
doesn't always return the correct key code due to the binary nature of floats. This can be avoided by replacing <int> by <round>. In this case <round> even doesn't need a second argument. For positive numbers it works like <ceil> from the math module.
Quote: print('key= '+str(round(log2(k))))

Things like this could drive you crazy.

Günter
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Python: some practice, questions and #%§' - Guenter Schink - 05-16-2021 10:17 AM



User(s) browsing this thread: 1 Guest(s)