Next / Previous / Contents / TCC Help System / NM Tech homepage

20.1. abs(): Absolute value

To find the absolute value of a number x:

abs(x)

If x is negative, the function returns -x; otherwise it returns x.

For complex values, the function returns the magnitude, that is, the square root of (x.real**2+x.imag**2).

>>> abs(-33)
33
>>> abs(33)
33
>>> abs(0)
0
>>> abs(complex(1,5))
5.0990195135927845