math - In Python 2, what is the difference between '/' and '//' when used for division? -


is there benefit using 1 on other? in python 2, both seem return same results:

>>> 6/3 2 >>> 6//3 2 

in python 3.0, 5 / 2 return 2.5 , 5 // 2 return 2. former floating point division, , latter floor division, called integer division.

in python 2.2 or later in 2.x line, there no difference integers unless perform from __future__ import division, causes python 2.x adopt behavior of 3.0

regardless of future import, 5.0 // 2 return 2.0 since that's floor division result of operation.

you can find detailed description @ https://docs.python.org/whatsnew/2.2.html#pep-238-changing-the-division-operator


Comments

Popular posts from this blog

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

c++ - How do I get a multi line tooltip in MFC -

unit testing - How to mock PreferenceManager in Android? -