What is the difference between module operator (//) and normal division (/). | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

What is the difference between module operator (//) and normal division (/).

Both shows the quotient. Is it that one returns float and other integer.

17th Jul 2016, 5:55 AM
Sarath Manoj
Sarath Manoj - avatar
2 Answers
+ 6
First one return integer (23//7=3) and second on return float (23/7=3.28...).have a nice day;-)
17th Jul 2016, 8:28 AM
vetarikisa
+ 3
Modulus operator returns the remainder of x%y while the divisor returns to result of dividing x/y. Meaning that modulus is really neat to use for wrapping around numbers that make it useful for indentation and several other features in graphics programming. Divison is simply a mathematical Division. Therefore modulus operator is used only when you require the remainder of dividing x by y (x/y). E.g. 7%3 = 1 and 7/3 = 2.333...
17th Jul 2016, 9:46 AM
James Lanzon
James Lanzon - avatar