How to Calculate the Square Root of a Float in C#

Chris picture Chris · Dec 3, 2010 · Viewed 48.6k times · Source

How can I calculate the square root of a Float in C#, similar to Core.Sqrt in XNA?

Answer

CodesInChaos picture CodesInChaos · Dec 3, 2010

Calculate it for double and then cast back to float. May be a bit slow, but should work.

(float)Math.Sqrt(inputFloat)