Purplemath What is the absolute value of a number? The absolute value of a number n is the distance of the number n from zero. The absolute value is denoted by vertical bars as | n |, and is read aloud as "the absolute value of enn".
The absolute value of a number, being the distance of that number from zero, will always be a positive number (or zero, if you're taking the absolue value of zero). Absolute values are never negative, because absolute value only asks "how far?", not "in which direction?" This means not only that | 3 | = 3, because 3 is three units to the right of zero, but also that | −3 | = 3, because −3 is three units to the left of zero.
I am trying to get always a positive number as a result from a calculation even when it is negative I want my script to convert it to a positive number similar to using the "|" character in maths. Is that possible in Pine Language?
Check out the
mathnamespace. There are many helper functions inclueding what you are looking formath.abs.