source: trunk/libs/newlib/src/newlib/libc/stdlib/abs.c @ 543

Last change on this file since 543 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 632 bytes
Line 
1/*
2FUNCTION
3<<abs>>---integer absolute value (magnitude)
4
5INDEX
6        abs
7
8SYNOPSIS
9        #include <stdlib.h>
10        int abs(int <[i]>);
11
12DESCRIPTION
13<<abs>> returns
14@tex
15$|x|$,
16@end tex
17the absolute value of <[i]> (also called the magnitude
18of <[i]>).  That is, if <[i]> is negative, the result is the opposite
19of <[i]>, but if <[i]> is nonnegative the result is <[i]>.
20
21The similar function <<labs>> uses and returns <<long>> rather than <<int>> values.
22
23RETURNS
24The result is a nonnegative integer.
25
26PORTABILITY
27<<abs>> is ANSI.
28
29No supporting OS subroutines are required.
30*/
31
32#include <stdlib.h>
33
34int
35abs (int i)
36{
37  return (i < 0) ? -i : i;
38}
Note: See TracBrowser for help on using the repository browser.