Math Functions

math.fabs()

Return the magnitude of a real number as a float, unlike abs which may preserve integer type.

Formal Syntax & Structure

python syntaxpython
math.fabs(x, /)

Parameters & Attributes

NameTypeDescription
xreal numberInput real value.

Return Value

float

Floating-point result; finite precision and domain restrictions apply.

Working Example

Example Snippetpython
import mathprint(math.fabs(-4))
Python Reference