What's the difference between abs and fabs?

后端 未结 3 1271
一向
一向 2020-12-15 04:41

I checked the difference between abs and fabs on python here

As I understand there are some difference regarding the speed and the passed t

3条回答
  •  心在旅途
    2020-12-15 05:33

    My Visual C++ 2008 didn't know which to choice from long double fabs(long double), float fabs(float), or double fabs(double).

    In the statement double i = -9;, the compiler will know that -9 should be converted to double because the type of i is double.


    abs() is declared in stdlib.h and it will deal with int value.

    fabs() is declared in math.h and it will deal with double value.

提交回复
热议问题