I have a number it could be negative or positive but I simply want to return the positive value.
-4 -> 4
5 -> 5
I know I can do a sim
You're looking for Math.Abs
.
Use System.Math.Abs
as documented here.
If you're working with floats in Unity, use Mathf.Abs
You can use Math.Abs
like public static int Abs (int value);
There is an overloaded method Math.Abs can be used in your case. It can take Double, Int16, Int32, Int64, SByte, Single or Decimal
as an argument.
Use this :
int PositiveNo = System.Math.Abs(NegativeNoHere);