int n1 = 10, n2 = 2; float f = (n1+0.0f)/n2; Casting n1 to float would also work, but I hope the compiler is smart enough to optimize away the plus expression.