Rev 4872 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4349 | Serge | 1 | /* |
2 | FUNCTION |
||
3 | < |
||
4 | |||
5 | INDEX |
||
6 | abs |
||
7 | |||
8 | ANSI_SYNOPSIS |
||
9 | #include |
||
10 | int abs(int <[i]>); |
||
11 | |||
12 | TRAD_SYNOPSIS |
||
13 | #include |
||
14 | int abs(<[i]>) |
||
15 | int <[i]>; |
||
16 | |||
17 | DESCRIPTION |
||
18 | < |
||
19 | @tex |
||
20 | $|x|$, |
||
21 | @end tex |
||
22 | the absolute value of <[i]> (also called the magnitude |
||
23 | of <[i]>). That is, if <[i]> is negative, the result is the opposite |
||
24 | of <[i]>, but if <[i]> is nonnegative the result is <[i]>. |
||
25 | |||
26 | The similar function < |
||
27 | |||
28 | RETURNS |
||
29 | The result is a nonnegative integer. |
||
30 | |||
31 | PORTABILITY |
||
32 | < |
||
33 | |||
34 | No supporting OS subroutines are required. |
||
35 | */ |
||
36 | |||
37 | #include |
||
38 | |||
39 | int |
||
40 | _DEFUN (abs, (i), int i) |
||
41 | { |
||
42 | return (i < 0) ? -i : i; |
||
43 | }> |