Math.Sqrt metod return double type by default due to performance.

If you want to find square root of a decimal number, you can use following code example

C# Code:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
class Program { static decimal SquereRoot(decimal square) { if (square < 0) return 0; decimal root = square / 3; int i; for (i = 0; i < 32; i++) root = (root + square / root) / 2; return root; } static void Main(string[] args) { decimal decimalNumber = 10.10m; Console.WriteLine("Square root of {0} decimal :{1}",decimalNumber, SquereRoot(decimalNumber)); Console.ReadLine(); } } |

**More Math.Sqrt example click here**