Search This Blog

Loading...

abs

  • abs (a macro) gets the absolute value of an integer. 
  • cabs and cabsl (macros) calculate the absolute value of a complex number.
  • fabs and fabsl calculate the absolute value of a floating-point number.
  • labs calculates the absolute value of a long number

Declaration:

abs
real:     int abs(int x);
complex:  double abs(complex x);
double cabs(struct complex z);
long double cabsl(struct _complexl (z));
double fabs(double x);
long double fabsl(long double @E(x));
long int labs(long int x);

Remarks:
All of these routines return the absolute value of their argument. abs,
cabs, and cabsl are macros; fabs and labs are functions.


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

  printf("number: %d  absolute value: %d\n", number, abs(number));
      return 0;

}

No comments:

Post a Comment