Converting the result of dividing, or multiplying, two integral expressions to a floating-point value may result in a loss of precision. For integral division, any fractional component of the result will be lost. For integral multiplication, the result may be outside the integral range and overflow.
For division, unless the intent is to round the result down to a whole number, you should cast one of the operands to a floating-point type before performing the division. For multiplication, unless the intent is to overflow, you should cast one of the operands to a floating-point type before performing the multiplication.
In this example
c is equal to 5 because integer division is performed.
Casting one of the integers to a float ensures that float division is used and
the remainder will be maintained, giving
c the value of 5.25.
In this example, if
a is greater than 536,870,911 the result will overflow.
Casting one of the integers to a float ensures that float multiplication is used and overflow is avoided.