🌐
Programiz
programiz.com › c-programming › library-function › math.h › fabs
C fabs() - C Standard Library
#include <stdio.h> #include <math.h> int main() { double x, result; x = -1.5; result = fabs(x); printf("|%.2lf| = %.2lf\n", x, result); x = 11.3; result = fabs(x); printf("|%.2lf| = %.2lf\n", x, result); x = 0; result = fabs(x); printf("|%.2lf| = %.2lf\n", x, result); return 0; }
🌐
Cppreference
en.cppreference.com › w › c › numeric › math › fabs
fabs, fabsf, fabsl, fabsd32, fabsd64, fabsd128 - cppreference.com
December 20, 2024 - #include <math.h> #include <stdio.h> #define PI 3.14159 // This numerical integration assumes all area is positive. double integrate(double f(double), double a, double b, // assume a < b unsigned steps) // assume steps > 0 { const double dx = (b - a) / steps; double sum = 0.0; for (double x = a; x < b; x += dx) sum += fabs(f(x)); return dx * sum; } int main(void) { printf("fabs(+3) = %f\n", fabs(+3.0)); printf("fabs(-3) = %f\n", fabs(-3.0)); // special values printf("fabs(-0) = %f\n", fabs(-0.0)); printf("fabs(-Inf) = %f\n", fabs(-INFINITY)); printf("Area under sin(x) in [-PI, PI] = %f\n", integrate(sin, -PI, PI, 5101)); }
🌐
TechOnTheNet
techonthenet.com › c_language › standard_library_functions › math_h › fabs.php
C Language: fabs function (Absolute Value of Floating-Point Number)
math.h · In the C Programming ... fabs(double x); x · The value to convert to an absolute value. The fabs function returns the absolute value of a floating-point number represented by x....
🌐
TutorialsPoint
tutorialspoint.com › c_standard_library › c_function_fabs.htm
C library - fabs() function
Here, we have two types of absolute value − positive and negative, and when these value are passes to the function fabs(), it display the result. #include <stdio.h> #include <math.h> int main() { double a = 9801.0; double b = -1831.0; double res; res = fabs(a); printf("The absolute value of %.3lf is %.3lf\n", a, res); res = fabs(b); printf("The absolute value of %.3lf is %.3lf\n", b, res); return 0; }
🌐
W3Schools
w3schools.com › c › ref_math_fabs.php
C Math fabs() Function
C Examples C Real-Life Examples C Exercises C Quiz C Code Challenges C Compiler C Syllabus C Study Plan C Interview Q&A C Certificate ... The fabs() function returns the absolute (positive) value of a number. The fabs() function is defined in ...
🌐
Vultr
docs.vultr.com › clang › standard-library › math-h › fabs
C math.h fabs() - Get Absolute Value | Vultr Docs
December 12, 2024 - The fabs() function from the C standard library's math.h header file is used to compute the absolute value of a floating-point number.
🌐
Cplusplus
cplusplus.com › reference › cmath › fabs
fabs
double fabs (double x); float fabs (float x);long double fabs (long double x); double fabs (T x); // additional overloads for integral types ... Returns the absolute value of x: |x|. Header <tgmath.h> provides a type-generic macro version of this function.
🌐
The Open Group
pubs.opengroup.org › onlinepubs › 009696899 › functions › fabs.html
fabs
This example shows the use of fabs() to compute the 1-norm of a vector defined as follows: ... where |x| denotes the absolute value of x, n denotes the vector's dimension v[i] denotes the i-th component of v (0<=i<n). #include <math.h> double norm1(const double v[], const int n) { int i; double n1_v; /* 1-norm of v */ n1_v = 0; for (i=0; i<n; i++) { n1_v += fabs (v[i]); } return n1_v; }
🌐
Codecogs
codecogs.com › library › computing › c › math.h › fabs.php
fabs - Math.h - C - C++ Computing Reference with Worked Examples
December 18, 2011 - #include <math.h> The fabs functions compute the absolute value of a floating-point number x, which is given by: (2) Example: 1 · Workings · #include <stdio.h> #include <math.h> int main(void) { float number = -1234.0; printf("number: %.2f absolute value: %.2f\n", number, fabs(number)); return ...
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › c language › fabs-function-in-c
fabs() Function in C - GeeksforGeeks
July 23, 2025 - fabs() function of math.h header file in C programming is used to get the absolute value of a floating point number.
🌐
W3Schools
w3schools.com › cpp › ref_math_fabs.asp
C++ Math fabs() Function
The fabs() function returns the absolute (positive) value of a number.
🌐
Microsoft Learn
learn.microsoft.com › en-us › cpp › c-runtime-library › reference › fabs-fabsf-fabsl
fabs, fabsf, fabsl | Microsoft Learn
July 28, 2025 - In a C program, unless you're using the <tgmath.h> macro to call this function, fabs always takes and returns a double.
🌐
Scaler
scaler.com › home › topics › fabs() function in c
fabs() Function in C - Scaler Topics
November 7, 2023 - fabs in C function takes a number as input and returns the magnitude of that number, i.e., ignore the sign of the number and return its absolute value. We must include the math.h header file to use the fabs in C function in C programming.
🌐
O'Reilly
oreilly.com › library › view › c-in-a › 0596006977 › re57.html
fabs - C in a Nutshell [Book]
December 16, 2005 - NamefabsSynopsisObtains the absolute value of a number#include <math.h> doublefabs( double x ); float fabsf( float x ); long double fabsl( long double x );The fabs() function... - Selection from C in a Nutshell [Book]
Authors   Peter PrinzTony Crawford
Published   2005
Pages   618
🌐
Try to Program
trytoprogram.com › home › learn c programming – easy c tutorials › c programming math library functions › c math library function fabs()
C Math Library Function fabs() - Explanation And Example
November 26, 2019 - fabs() is the standard C math library function that is defined in math library math.h and it returns the absolute value of number passed as an argument.
🌐
Programiz
programiz.com › cpp-programming › library-function › cmath › fabs
C++ fabs() - C++ Standard Library
The fabs() function in C++ returns the absolute value of the argument. It is defined in the cmath header file. Mathematically, fabs(num) = |num|.
🌐
Codecogs
codecogs.com › library › computing › c › math.h › fabs.php
fabsf - Math.h - C - C++ Computing Reference with Worked Examples
September 11, 2024 - #include <math.h> The fabs functions compute the absolute value of a floating-point number x, which is given by: (2) Example: 1 · Workings · #include <stdio.h> #include <math.h> int main(void) { float number = -1234.0; printf("number: %.2f absolute value: %.2f\n", number, fabs(number)); return ...
🌐
GNU
gnu.org › software › libc › manual › html_node › Absolute-Value.html
Absolute Value (The GNU C Library)
July 23, 2025 - Prototypes for abs, labs, llabs, uabs, ulabs and ullabs are in stdlib.h; imaxabs and uimaxabs are declared in inttypes.h; the fabs functions are declared in math.h; the cabs functions are declared in complex.h.