Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
6536 serge 1
/*
2
FUNCTION
3
<>---long integer absolute value
4
 
5
INDEX
6
	labs
7
 
8
ANSI_SYNOPSIS
9
	#include 
10
	long labs(long <[i]>);
11
 
12
TRAD_SYNOPSIS
13
	#include 
14
	long labs(<[i]>)
15
	long <[i]>;
16
 
17
DESCRIPTION
18
<> returns
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 <> uses and returns <> rather than
27
<> values.
28
 
29
RETURNS
30
The result is a nonnegative long integer.
31
 
32
PORTABILITY
33
<> is ANSI.
34
 
35
No supporting OS subroutine calls are required.
36
*/
37
 
38
#include 
39
 
40
long
41
_DEFUN (labs, (x),
42
	long x)
43
{
44
  if (x < 0)
45
    {
46
      x = -x;
47
    }
48
  return x;
49
}