- Home /
How do I get the square root of a double number value?
i am using big numbers, so I use a double variable, and mathf.sqrt does not work with doubles, is there another way?
Answer by Captain_Pineapple · Aug 08, 2018 at 09:10 AM
Hey there,
the Mathf.sqrt function is for floats as the Mathf indicates.
Using Math.Sqrt should work for doubles. In case that is not naturally in your script then append a using System;
or just write System.Math.Sqrt();
hope this helps! Here is the link for the msdn reference.
Note that Unity's $$anonymous$$athf class is mostly a wrapper of the default .NET System.$$anonymous$$ath class with additional casting. See the Sqrt implementation. This is mainly for convenience since our main data type is float
Answer by Legend_Bacon · Aug 08, 2018 at 09:07 AM
Hello there,
This thread might prove a good read for you.
Basically, use Math.Sqrt instead!
Hope that helps!
Cheers,
~LegendBacon
Your answer
Follow this Question
Related Questions
Side scroller spawns at different Y 1 Answer
My Algorithm for checking whole tiles didint work 0 Answers
Unity - halo doesn't work all the time 0 Answers
how to stop player from automatically jumping on a moving platform 0 Answers
Is it correct to animate the player spritesheet and external gameobjects in the same animation? 0 Answers