Embedded Artistry libc
C Standard Library Support for Bare-metal Systems
abs.c File Reference
#include <stdlib.h>
Include dependency graph for abs.c:

Go to the source code of this file.

Functions

int abs (int j)
 Computes the absolute value of an integer number. More...
 

Function Documentation

◆ abs()

int abs ( int  n)

Computes the absolute value of an integer number.

Computes the absolute value of an integer number. The behavior is undefined if the result cannot be represented by the return type.

Parameters
ninteger value
Returns
The absolute value of n (i.e. |n|), if it is representable.

Definition at line 32 of file abs.c.

33 {
34  return (j < 0 ? -j : j);
35 }