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 simple if check, see if its zero then return it *-1
but I can't remember for the life of me what the actual Maths
operator is!
Can anyone tell me what it is?
ABS Formula In Excel In Excel, you compute the absolute value using the formula function ABS. With the formula =ABS(-5), Excel converts the negative to positive and gives the result 5. You can wrap a larger computation in the ABS function to make the result always positive.
The abs() function is used to get the absolute (positive) value of a given number.
a = -0.340515; to convert this into positive number I used the abs() method as: a = abs(a);
Use System.Math.Abs
as documented here.
You're looking for Math.Abs
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With