Get the dual accuracy of the C#integer removal method
C#integer removal of the decimal part, only the integer result is returned. But sometimes we need to get dual -precision floating -point results.
To achieve this, the number of operations can be converted into
type before the division operation. For example:
double
<code class="language-csharp">double num3 = (double)num1 / (double)num2;</code>
and then perform dividends. The result will be the num1
type. This is because the integer is converted to num2
to store the value of the integer into a floating point number. double
double
It should be noted that if any operation in C#is double
type, the floating point removal method will be performed, and the result is also
double
double
For more information about floating -point operations and type conversion in C#, please refer to dot net perls:
<code class="language-csharp">double num3 = (double)num1 / num2;</code>
The above is the detailed content of How Can I Get a Double Result from Integer Division in C#?. For more information, please follow other related articles on the PHP Chinese website!