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

    In Python 3.x, 5 / 2 will return 2.5 and 5 // 2 will return 2. The former is floating point division, and the latter is floor division, sometimes also called integer division. In Python 2.2 or later in the 2.x line, …

  2. What is the reason for having '//' in Python? - Stack Overflow

    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 / operator was …

  3. 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?

  4. 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...

  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. python - How can I force division to be floating point? Division keeps ...

    How can I force division to be floating point in Python? I have two integer values a and b, but I need their ratio in floating point. I know that a < b and I want to calculate a/b, so if I use integer division I'll …

  7. How do I get a decimal value when using the division operator in …

    Aug 9, 2024 · 5 You need to tell Python to use floating point values, not integers. You can do that simply by using a decimal point yourself in the inputs:

  8. python - Why does integer division yield a float instead of another ...

    0 In Python 3, the standard division operator (/) always performs "true division" and returns a float result, even if both operands are integers and the division results in a whole number.

  9. python - Find the division remainder of a number - Stack Overflow

    That's because Python's % performs a true modulus, which returns values on the range [0, divisor) and pairs well with floored division (towards negative infinity). C languages use the % operator for …

  10. Python 3 operator.div? - Stack Overflow

    There is no operator.div in Python 3, no; that only existed in Python 2. There is a operator.truediv() function instead, as well as a operator.floordiv() function. The reason for this division (no pun …