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