The Double Division operator in Python returns the floor value for both integer and floating-point arguments after division.
2 -3 2.0
The single division operator behaves abnormally generally for very large numbers. Consider the following example.
500000001.0 50000000000000000 50000000000000001
The Output should have been Hello if the single division operator behaved normally because 2 properly divides x. But the output is World because The results after Single Division Operator and Double Division Operator ARE NOT THE SAME.
This fact can be used for programs such as finding the sum of first n numbers for a large n.
Sum using single division operator : 50000000005000003584 Sum using double division operator : 50000000005000000000
Thus the result found by using the single division operator is Wrong, while the result found by using the double division operator is Correct. This is a huge benefit of Double Division Operator over Single Division Operator in Python.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- Check the equality of integer division and math.floor() of Regular division in Python
- Single and Double Quotes | Python
- What does the Double Star operator mean in Python?
- Python Iterate over multiple lists simultaneously
- Iterate over a dictionary in Python
- Iterate over a set in Python
- Iterate over characters of a string in Python
- Python | Swapping sublists over given range
- Python - Constant Multiplication over List
- Iterate over words of a String in Python
- Python - Iterate over Columns in NumPy
- Python Bokeh – Plotting glyphs over a Google Map
- Loop or Iterate over all or certain columns of a dataframe in Python-Pandas
- How to Iterate over Dataframe Groups in Python-Pandas?
- Benefit of NumPy arrays over Python arrays
- Iterate over a list in Python
- Python | Convert Triple nesting to Double nesting list
- Python - Double each List element
- Python - Double each consecutive duplicate
- Python | Printing String with double quotes
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.