- Home /
Question by
PH-zero · Feb 11, 2013 at 05:37 PM ·
mathsquare root
Return a value always positiv
Hi there
i know that .ToString always return the value as a String.
for example: number.ToString
But is there somthing like .ToPositive?
i mean return the value always positiv, no matter if the variable is negative or positive.
for example:
var minusnumber = -3;
var number = 0;
number = minusnumber.ToPositive;
The Result: number = 3. Is this possible in that way or do you have to do somthing like this:
minusnumber=minusnumber*minusnumber;
number=minusnumber.ToSquareRoot;
or is there an even smarter way? Thanks in advance =)
Comment
Answer by Itinerant · Feb 11, 2013 at 05:39 PM
Basically, you want to take the absolute value of your number. So put it in a Mathf.abs(number) and you're good to go.
Your answer
Follow this Question
Related Questions
square root? 1 Answer
Writing maths expressions 1 Answer
How to get vector X distance from point on Y angle? 4 Answers
Basic vector math addition 1 Answer