What does fabs in c language mean?
The fabs function is a function that finds the absolute value. Finding the absolute value of x is the same as the mathematical concept. The function prototype is extern float fabs(float x), and the usage is #include .
Recommended learning: c language video tutorial
Declaration of fabs() function: double fabs(double x). The parameter x is a floating point value, and this function returns the absolute value of x. The code example is as follows:
int main (){ int a, b; a = 1234; b = -344; printf("The absolute value of %d is %lf", a, fabs(a)); printf("The absolute value of %d is %lf", b, fabs(b)); return(0);}
Compile and run the above program, which will produce the following results:
The absolute value of 1234 is 1234.000000 The absolute value of -344 is 344.000000
Extended information:
fabs The difference between () and abs():
(1) Different parameter objects
abs() takes the absolute value of the integer, while fabs() takes the absolute value of the floating point number.
(2) The function prototype is different:
int abs(int x) double fabs(double x)
(3) The header file is different:
abs(): #include <stdlib.h> fabs(): #include <math.h>
The above is the detailed content of What does fabs mean in c language?. For more information, please follow other related articles on the PHP Chinese website!