Description: The method in Python fabs(x)
Returns the absolute value of x . Although similar to abs()
a function, the following differences exist between the two functions:
abs()
is a built-in function that is fabs()
defined in a math
module.
- The
fabs()
function is only available for float and integer types, and abs()
also for complex numbers .
- ABS () return is float and int type, math.fabs () return is float type
Syntax: here is fabs()
the syntax for the method:
Import Mathmath.fabs (x)
Note: This module cannot be accessed directly, requires calling math
the module, and then math
calls this function with a static object.
Parameters x is the incoming parameter.
return value The absolute value of the returned x .
Example
Import Math
A =-1
b =-1.3232
c = b
D = 1+1.0j
E = 3+4.0j
f =-230.13000
Print ("ABS () absolute value of output a:", ABS (a))
Print ("fabs () absolute value of output a", Math.fabs (a))
Print ("ABS () absolute value of output B:", ABS (b))
Print ("absolute value of output C:", Math.fabs (c))
Print ("absolute value of output D:", ABS (d))
Print ("absolute value of output e:", ABS (E))
# Print ("fabs () output e absolute value:", Math.fabs (e))
Print ("abs () output F absolute value:", ABS (f))
Print (the absolute value of the "fabs () output F:", Math.fabs (f))
Output
ABS () absolute value of output a: 1
Fabs () absolute value of output a 1.0
ABS () absolute value of output B: 1.3232
Absolute value of output C: 1.3232
Absolute value of output D: 1.4142135623730951
Absolute value of output E: 5.0
ABS () absolute value of output F: 230.13
Fabs () absolute value of output F: 230.13
The difference between ABS () and Math.fabs () in Python