About 4,570,000 results
Open links in new tab
  1. math - `/` vs `//` for division in Python - Stack Overflow

    In Python 2.2 or later in the 2.x line, there is no difference for integers unless you perform a from __future__ import division, which causes Python 2.x to adopt the 3.x behavior. Regardless of …

  2. python - Why does the division get rounded to an integer

    In Python 3, the “//” operator works as a floor division for integer and float arguments. However, the operator / returns a float value if one of the arguments is a float (this is similar to C++)

  3. division - What is the reason for having '//' in Python ... - Stack ...

    Oct 8, 2009 · In Python 3, they made the / operator do a floating-point division, and added the // operator to do integer division (i.e., quotient without remainder); whereas in Python 2, the / …

  4. python - How do you round UP a number? - Stack Overflow

    May 5, 2017 · The problem is that dividing two ints in python produces another int and that's truncated before the ceiling call. You have to make one value a float (or cast) to get a correct …

  5. Integer division in Python 2 and Python 3 - Stack Overflow

    In Python 2.7, the / operator is integer division if inputs are integers. If you want float division (which is something I always prefer), just use this special import:

  6. math - Basic python arithmetic - division - Stack Overflow

    15 Python does integer division when both operands are integers, meaning that 1 / 2 is basically "how many times does 2 go into 1", which is of course 0 times. To do what you want, convert …

  7. Python 3 integer division - Stack Overflow

    In Python 3 vs Python 2.6, I've noticed that I can divide two integers and get a float. How do you get the Python 2.6 behaviour back? Is there a different method to get int/int = int?

  8. python - What is the python3's magic method for Division

    Mar 31, 2020 · What is the python3's magic method for Division? In most websites it is stated that __div__ is the magic method for division but __div__ doesn't work. What's the magic method …

  9. Is there a ceiling equivalent of // operator in Python?

    I found out about the // operator in Python which in Python 3 does division with floor. Is there an operator which divides with ceil instead? (I know about the / operator which in Python 3 does fl...

  10. python - How to return 0 with divide by zero - Stack Overflow

    17 Try doing it in two steps. Division first, then replace. with numpy.errstate(divide='ignore'): result = numerator / denominator result[denominator == 0] = 0 The numpy.errstate line is optional, …