+ 20

0.0
If you want 0.5, then at least one operand must be floating point number. Since both 1 and 2 are integers, the value of 1/2 is 0. Then because d is double, the result is 0.0
Use 1.0/2 or 1.0/2.0 or 1/2.0

+ 20

0.0
If you want 0.5, then at least one operand must be floating point number. Since both 1 and 2 are integers, the value of 1/2 is 0. Then because d is double, the result is 0.0
Use 1.0/2 or 1.0/2.0 or 1/2.0