Skip to main content

math.fabs(value)

Returns absolute value as float

Availability

Device + Agent

Parameters

Name Type Description
value Float/integer Any numerical value

Returns

Float — the absolute value

Description

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

This function returns a floating-point value, so when passed -10, it will return 10.0 not 10.

Example Code

The math.fabs() method 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.