Skip to main content
2 of 5
added 67 characters in body

In C/C++ and Java, why does dividing an integer by an integer return an integer, while in other languages, it returns a decimal value?

I have found another similar question, but the answer there talks mainly about C/C++, and does not mention about the division operator. So, in C/C++ and Java, dividing an integer by an integer returns an integer. On the other hand, in Python, a single slash will return a floating point while a double slash will return an integer. And I currently do not know about Perl and Ruby. Why does the division operator work like this in different languages?