๐ŸŒ
Programiz
programiz.com โ€บ c-programming โ€บ library-function โ€บ math.h โ€บ fabs
C fabs() - C Standard Library
Become a certified C programmer. Try Programiz PRO! ... The fabs() function takes a single argument (in double) and returns the absolute value of that number (also in double).
๐ŸŒ
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.
Discussions

Homemade 'fabs' function in C and x86 Assembly - Stack Overflow
I'm trying to make in GNU C an fabs function that returns the absolute value of a 32 bits float. I have three different ways, called fabs1, fabs2, and fabs3: #include #include More on stackoverflow.com
๐ŸŒ stackoverflow.com
c - Want to find absolute value using fabs and my own absolute value function - Stack Overflow
Trying to learn functions by playing around with the library and creating my own code. I created my own absolute value func to compare and contrast. expected input: -10 expected output: The library More on stackoverflow.com
๐ŸŒ stackoverflow.com
Simple C Question on abs() and fabs()
It is just truncating for you and returning an int. What behavior were you expecting? More on reddit.com
๐ŸŒ r/AskProgramming
8
5
October 22, 2020
What does the function "fabs(_:)" โ€ฆ | Apple Developer Forums
That meant the floating point versions needed different names, so: "fabs", "fabsf" and "fabsl", with the initial "f" meaning "floating point". This is a common gotcha in C programming, because if "myValue" is a variable of type "double" (say), and you write "double result = abs (myValue)", ... More on developer.apple.com
๐ŸŒ developer.apple.com
๐ŸŒ
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.
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ c_standard_library โ€บ c_function_fabs.htm
C library - fabs() function
The C math library fabs() function accepts the parameter(x) of type double that returns the absolute value of x. This function is defined under the header that calculates the absolute value of a float point number.
๐ŸŒ
O'Reilly
oreilly.com โ€บ library โ€บ view โ€บ c-in-a โ€บ 0596006977 โ€บ re57.html
fabs - C in a Nutshell [Book]
December 16, 2005 - float x = 4.0F * atanf( 1.0F ); long double y = 4.0L * atanl( 1.0L ); if ( x == y ) printf( "x and y are exactly equal.\n" ); else if (fabs( x โˆ’ y ) < 0.0001 * fabsl( y ) ) printf( "x and y are approximately equal:\n" "x is %.8f; y is %.8Lf.\n", x, y ); ... The absolute value functions for integer types: abs(), labs(), llabs(), and imaxabs(); the absolute value functions for complex numbers: cabs(), cabsf(), cabsl(); the C99 functions fdim() and copysign(); the functions fmax() and fmin()
Authors ย  Peter PrinzTony Crawford
Published ย  2005
Pages ย  618
๐ŸŒ
Cppreference
en.cppreference.com โ€บ w โ€บ c โ€บ numeric โ€บ math โ€บ fabs.html
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)); }
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 77073189 โ€บ homemade-fabs-function-in-c-and-x86-assembly
Homemade 'fabs' function in C and x86 Assembly - Stack Overflow
The compiler is permitted to do operations at higher precision, so when you use fabs (which may be builtin and returns a double), you may get the value 189.55000000000001136868377216160297393798828125 (the closest you can get with double precision -- 0x1.7b1999999999ap+7 in hex), but all your handwritten functions return the float value of 189.5500030517578125
Find elsewhere
๐ŸŒ
Oreate AI
oreateai.com โ€บ blog โ€บ the-fabs-function-in-c-language โ€บ cc8da5bb8b9119de9f6bb45aa5dd6034
The Fabs Function in C Language - Oreate AI Blog
December 22, 2025 - The fabs function is a mathematical function in the C programming language used to calculate the absolute value of a number. Its header file is #include <math.h>, and its prototype is double fabs(double x). This function returns the absolute ...
๐ŸŒ
Microsoft Learn
learn.microsoft.com โ€บ en-us โ€บ cpp โ€บ c-runtime-library โ€บ reference โ€บ fabs-fabsf-fabsl
fabs, fabsf, fabsl | Microsoft Learn
July 28, 2025 - Calculates the absolute value of the floating-point argument. double fabs( double x ); float fabs( float x ); // C++ only long double fabs( long double x ); // C++ only float fabsf( float x ); long double fabsl( long double x ); #define fabs(X) ...
๐ŸŒ
Scaler
scaler.com โ€บ home โ€บ topics โ€บ fabs() function in c
fabs() Function in C - Scaler Topics
November 7, 2023 - The fabs in C is a library function provided within the math.h header file of the C programming language.
๐ŸŒ
CodeToFun
codetofun.com โ€บ c โ€บ math-fabs
C fabs() Function | CodeToFun
November 16, 2024 - The fabs() function is a standard library function in C that is used to calculate the absolute value (magnitude) of a given floating-point value.
๐ŸŒ
Sarthaks eConnect
sarthaks.com โ€บ 3511074 โ€บ explain-fabs-math-function-in-c
Explain fabs() Math Function in C - Sarthaks eConnect | Largest Online Education Community
LIVE Course for free ยท In the C programming language, the fabs() function is a mathematical function used to calculate the absolute value of a floating-point number. It is defined in the <math.h> header file and can be used to find the magnitude ...
๐ŸŒ
Aticleworld
aticleworld.com โ€บ home โ€บ fabs function in c
fabs function in C - Aticleworld
September 28, 2021 - The fabs function in C computes the absolute value of a floating-point number x. The x is the argument that is passed into the fabs().
๐ŸŒ
Reddit
reddit.com โ€บ r/askprogramming โ€บ simple c question on abs() and fabs()
r/AskProgramming on Reddit: Simple C Question on abs() and fabs()
October 22, 2020 -

Hi guys, I know that abs() takes in an int and returns an int, while fabs() takes in a float/double and returns a float/double.

However, if I pass in an int to fabs, it works as per usual, but not when I pass a double into abs. I would expect some syntax error to appear or smth, or does type promotion occur here, where the int gets promoted to a double and so fabs() work as per usual?

๐ŸŒ
Apple Developer
developer.apple.com โ€บ forums โ€บ thread โ€บ 90710
What does the function "fabs(_:)" โ€ฆ | Apple Developer Forums
That meant the floating point versions needed different names, so: "fabs", "fabsf" and "fabsl", with the initial "f" meaning "floating point". This is a common gotcha in C programming, because if "myValue" is a variable of type "double" (say), and you write "double result = abs (myValue)", it looks like you are taking the absolute value, but the C compiler [correctly and automatically] converts the double to an int by truncating it, computes the absolute value of the truncated integer, converts it back to a double, and this isn't the answer you wanted.
๐ŸŒ
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. This function is essential in various programming scenarios, particularly in fields requiring precise mathematical ...
๐ŸŒ
Krayonnz
krayonnz.com โ€บ user โ€บ doubts โ€บ detail โ€บ 61894a1591cca20041786b9f โ€บ difference-between-abs-and-fabs-functions-in-C
Difference between abs() and fabs() functions in C ?
The fastest growing social learning network of students. Participate in quizzes and competitions to win cash & exciting prizes. Host your college competitions & quizzes. Buy & Sell verified notes. Ask & answer doubts.