Use of absolute value functions abs and FABS

Source: Internet
Author: User
Evaluate the absolute value of a number. Supported by library functions provided by VC ++, when it must include: # include <math. h>
 
There are several types: ABS, _ abs64, FABS, fabsf,Labs,_ Cabs. Details are as follows:
//Calculate the absolute value.
int abs(    int n );long abs(    long n );   // C++ onlydouble abs(    double n );   // C++ onlylong double abs(   long double n);   // C++ onlyfloat abs(   float n );   // C++ only__int64 _abs64(    __int64 n );
//Calculates the absolute value of the floating-point argument.
double fabs(    double x );float fabs(   float x ); // C++ onlylong double fabs(   long double x); // C++ onlyfloat fabsf(    float x );
//Calculates the absolute value of a long integer.
long labs(      long n );

//Calculates the absolute value of a complex number.

double _cabs(    struct _complex z );

The prototype of the above function is from msdn2008. It can be seen that there are many overloaded functions in ads. Generally, ADS () can meet the requirements (C ++). Other cases are special cases.
You can also use a template to redefine it.

Use of absolute value functions abs and FABS

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.