RAD Studio |  |

fabs, fabsl

Header File

math.h

Category

Math Routines

Prototype

double fabs(double x);

long double fabsl(long double x);

Description

Returns the absolute value of a floating-point number.

fabs calculates the absolute value of x, a double. fabsl is the long double version; it takes a long double argument and returns a long double result.

Return Value

fabs and fabsl return the absolute value of x.

Example

Copy Code

    #include <stdio.h>
    #include <math.h>
    int main(void)
    {
       float  number = -1234.0;

       printf("number: %f  absolute value: %f\n", number, fabs(number));
       return 0;
    }

Portability

| POSIX | Win32 | ANSI C | ANSI C++
fabs | + | + | + | +
fabsl |  | + | + | +

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!