(totalOptCount/totalRespCount)
here both dividend and divisor are of type int
which means they will allow only integer values and the answer of such equation will always be an integer literal.
if I break this it will be something like below
(double)(500/1500)
According to the actual calculation, 500/1500 will give you 0.33333 but compiler will convert this into integer literal because both operands are of type int
(double)(0)
Compiler gets an instruction to cast this 0
value to double so you got 0.0
as result
0.0
and then you can change the result to any format as suggeted by @Zach Janicki.
keep in mind if both the operands are of same type than result will be of same type too.