truncating division : Divide « Language Basics « Python






truncating division

truncating division
x = 10

count = 0

while x > 0:
    x = x // 2
    count += 1

print "The approximate log2 is", count

           
       








Related examples in the same category

1.Divided by int or by floatDivided by int or by float
2.Read a number and do the divide by 2Read a number and do the divide by 2
3.Divide in PythonDivide in Python