math.fabs()
Anonymous contributor
Published Sep 11, 2024
Contribute to Docs
The math.fabs()
function takes a numeric value and returns its absolute value as a float. Unlike math.abs(), which can return the absolute value in the same type as the input, math.fabs()
always converts the result to a float. Passing any non-numeric data type will raise a TypeError
.
Syntax
math.fabs(n)
n
: A numeric value for which the absolute value is to be computed.
Example
Below is an example of math.fabs()
to return the floating-point absolute of the given value:
import mathprint(math.fabs(-154.2))
The above code prints the following output:
154.2
Codebyte Example
Run the following code to understand how the math.fabs()
function works:
All contributors
- Anonymous contributor
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.