How to get difference between two values
Ok. You guys know the good ol' useful: "if(Vector3.Distance(Pos1, Pos2) > Value)", right?
Now I have a question. How in the world can I apply that same method to 2 simple floats or intigers?
I have 2 floats in a script of mine. And I need to get the value difference between the two. It doesn't matter how large the floats may be. They both could be 10310 and 10350. But the difference between them would still be 40. So how do I get that value difference?
Answer by tanoshimi · Dec 24, 2016 at 07:58 AM
if(Mathf.Abs(num1 - num2) > Value)
Can anybody explain that? noob like me don't understand :'(
https://en.wikipedia.org/wiki/Absolute_difference
The absolute difference of two real numbers x, y is given by |x − y|, the absolute value of their difference. It describes the distance on the real line between the points corresponding to x and y.
Answer by abyboyganteng · Feb 16, 2021 at 08:16 AM
I maned my own fungtion:
int diffrence(int num1,int num2)
{
int cout;
cout = Mathf.Max(num2, num1) - Mathf.Min(num1, num2);
return cout;
}
example:
int myExemple = difference(13,10);
it mean my example is 3
Your answer
