How can I divide two integers to get a double?
c#, double, int, math
Solution
You want to cast the numbers:
double num3 = (double)num1/(double)num2;
Note: If any of the arguments in C# is a `double`, a `double` divide is used which results in a `double`. So, the following would work too:
double num3 = (double)num1/num2;
For more information see:
Dot Net Perls
Problem
How do I divide two integers to get a double?