1/9 is zero because 1 and 9 are integers and are divisible by integer divisions. The same goes for 4/9 .
If you want to express floating point division through arithmetic literals, you need to either use floating point literals 1.0/9 + 1.0/9 + 4.0/9 (or 1/9. + 1/9. + 4/9. Or 1.f/9 + 1.f/9 + 4.f/9 ), or explicitly use one operand for the desired floating point type (double) 1/9 + (double) 1/9 + (double) 4/9 .
PS Finally, my chance to answer this question :)
source share