What is math.abs exactly doing?

math.abs() is a built-in lua method (function), that enables you to find an absolute value.

What is an absolute value? It is a aboslute, non-negative value of any real number.

x = -5   ;   |x| = 5
y = 5    ;   |y| = 5

Read more about absolute values here: Absolute value - Wikipedia.

EDIT @Iwantbebetter

Rounding is a different operation.
It is basically shortening of a number to approximate value that is closer to integer values, e.g. 1.6 is close to 2; 1.4 is close to 1.

Positive values:

math.round(1.4) --> 1
math.round(1.5) --> 2

Negative values:

math.round(-2.4) --> -2
math.round(-2.5) --> -3

( -2 > -3)

Read more about various built-in mathematical operations in lua by following this link:

7 Likes