Home > Backend Development > C#.Net Tutorial > What does fabs mean in c language?

What does fabs mean in c language?

藏色散人
Release: 2020-02-06 11:57:05
Original
45157 people have browsed it

What does fabs mean in c language?

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);}
Copy after login

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
Copy after login

What does fabs mean in c language?

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)
Copy after login

(3) The header file is different:

abs(): #include <stdlib.h>
fabs(): #include <math.h>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template