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


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);

solved C# – Math.Sqrt() returning decimals