It's the order of operations.
(double) (total/10) evaluates as such:
1. take the integer total and divide by the integer 10. This is an integer number.
2. Cast that number to a double. An integer casted to a double looks like an integer.
Now if you have the other way around,
(double)total / 10:
1. cast total to double.
2. Divide the double value of total by the integer 10. 10 is implicitly casted to a double before the division, the result is a decimal number.
This second form is equivalent to ((double)total)/10