**New course!**Every coder should learn

**Generative AI!**

0

# Division

Hi there. I get the point and I quit appreciate the concept. But having the division operator choice returning an integer is odd, isn't it? In most cases an integer divided by another integer will result in a float or double. Will there be an error or some sort of round value? Thanks.

1 Answer

0

If you divide an integer by another, it will give an integer. But if you divide a float by an integer, it will give a float. Modern languages saved the old syntax, for example from Pascal, when an integer could be divided only by "div" - division and "mod" - module and the / division could be used only by "real" type, or float. So to be simpler, in modern langauges the / division was made global, and only changes in the calculus and logical use. If you want a float from a division of 2 int just make this: int x = (float)12 for a quick conversion. But in most cases you'll want an int.