On this page
math.fabs
Prev: math.expm1 | Up: math | Next: math.factorial
Rel: math.acos, math.acosh, math.asin, math.asinh
Ref: docs.python.org — math.fabs
Tags: #public #python3 #stdlib #math
Import
import math
from math import fabs
Signature & Overview
math.fabs(x, /)
Return the absolute value of the float x.
Usage
import math
assert math.fabs(-5) == 5.0 and isinstance(math.fabs(-5), float)
Gotchas
- Always returns
float(and rejectscomplex): Use built-inabs()when you wantintpreserved or complex magnitudes.
REPL Inspect
from math import fabs
help(fabs)
Linked from
Related notes
- tuts/python3/stdlib_module/math/expm1 Linked here; links to this page; shared tags: #math, #stdlib
- tuts/python3/stdlib_module/math/factorial Linked here; links to this page; shared tags: #math, #stdlib
- tuts/python3/stdlib_module/math Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/math/acos Linked here; shared tags: #math, #stdlib
- tuts/python3/stdlib_module/math/acosh Linked here; shared tags: #math, #stdlib
- tuts/python3/stdlib_module/math/asin Linked here; shared tags: #math, #stdlib
- tuts/python3/stdlib_module/math/asinh Linked here; shared tags: #math, #stdlib
- tuts/c/stdlib/math shared tags: #math, #stdlib
- tuts/c/stdlib/math/fabs shared tags: #math, #stdlib
- tuts/c/stdlib/math/floor shared tags: #math, #stdlib