Keil Logo

abs

Summary
#include <math.h>
/* or */
#include <stdlib.h>

int abs (
  int val);     /* number to take absolute value of */
Description

The abs function determines the absolute value of the integer val.

Return Value

The abs function returns the absolute value of val.

See Also

fabs, labs

Example
#include <math.h>
#include <stdio.h> /* for printf */

void tst_abs (void) {
  int x;
  int y;

  x = -42;
  y = abs (x);

  printf ("ABS(%d) = %d\n", x, y);
}
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.