Skip to main content

math.abs(value)

Returns an absolute value as an integer

Availability

Device + Agent

Parameters

Name Type Description
value Float/integer Any numerical value

Returns

Integer — the absolute value

Description

This function returns the absolute value of the passed number: its magnitude without the sign. Negative numbers become positive; positive numbers stay as they are. So the absolute value of -10 is 10, while the absolute value of 42 is 42.

This function returns an integer, so if -10.014 is passed, math.abs() will return 10, not 10.014.

Example Code

The math.abs() function is particularly useful for calculating the difference between two values when you are unsure which of the two may be the highest, so taking one from from the offer could yield either positive or a negative number.