[Solved] C# – Math.Sqrt() returning decimals

[ad_1]

Casting to integer (Int32) drops the fractional part of your number…

    int number = (Int32) 3.14159;  // value of number will be 3 (not 3.14159)
    // Do this instead
    double c = Math.Sqrt(c2); // will give you the result you want
    output.Text = Convert.ToString(c);

[ad_2]

solved C# – Math.Sqrt() returning decimals