In C++, 5/9 computes the result as an integer as both the operands are integers. You need to give an hint to the compiler that you want the result as a float/double. You can do it by explictly casting one of the operands like ((double)5)/9;
EDIT
Since it is tagged C++, you can do the casting bit more elegantly using the static_cast
. For example: static_cast<double>(5)/9
. Although in this particular case you can directly use 5.0/9 to get the desired result, the casting will be helpful when you have variables instead of constant values such as 5.