The division operation in line 13 is an integer division and therefore subject to truncation. You would have to do an explicit cast of either operand to double to force floating point arithmetic.
I said ONE of the operands of the division. That is not what I said. What you show there is the cast of the result of the division, AFTER the operands have played their part. Do the cast only on one of the operands; either 'a' or 'b'. For sure on 'a' works.