How do I find squareroot of float variable? | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
0

How do I find squareroot of float variable?

In my quest of finding the distance between two points, i couldn't use "^" with float and double.

29th Dec 2016, 2:47 AM
Sangam Gyawali
Sangam Gyawali - avatar
3 Réponses
0
You could cast it to double, use https://msdn.microsoft.com/en-us/library/system.math.sqrt(v=vs.110).aspx and recast it to float
30th Dec 2016, 6:29 PM
Sérgio Fernando Martins Borges Gutierres
0
i can't use ^even in double @sérgio
31st Dec 2016, 1:59 AM
Sangam Gyawali
Sangam Gyawali - avatar
0
float val = 9.657f; val = (float)Math.Sqrt((double)val); Console.WriteLine(val); You must not be doing it right, cause this works. Avoid the ^ operator alltogether
31st Dec 2016, 2:11 PM
Sérgio Fernando Martins Borges Gutierres