sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
* FUNCTION
|
sl@0
|
16 |
* <<abs>>---integer absolute value (magnitude)
|
sl@0
|
17 |
* INDEX
|
sl@0
|
18 |
* abs
|
sl@0
|
19 |
* ANSI_SYNOPSIS
|
sl@0
|
20 |
* #include <stdlib.h>
|
sl@0
|
21 |
* int abs(int <[i]>);
|
sl@0
|
22 |
* TRAD_SYNOPSIS
|
sl@0
|
23 |
* #include <stdlib.h>
|
sl@0
|
24 |
* int abs(<[i]>)
|
sl@0
|
25 |
* int <[i]>;
|
sl@0
|
26 |
* <<abs>> returns
|
sl@0
|
27 |
* @tex
|
sl@0
|
28 |
* $|x|$,
|
sl@0
|
29 |
* @end tex
|
sl@0
|
30 |
* the absolute value of <[i]> (also called the magnitude
|
sl@0
|
31 |
* of <[i]>). That is, if <[i]> is negative, the result is the opposite
|
sl@0
|
32 |
* of <[i]>, but if <[i]> is nonnegative the result is <[i]>.
|
sl@0
|
33 |
* The similar function <<labs>> uses and returns <<long>> rather than <<int>> values.
|
sl@0
|
34 |
* RETURNS
|
sl@0
|
35 |
* The result is a nonnegative integer.
|
sl@0
|
36 |
* PORTABILITY
|
sl@0
|
37 |
* <<abs>> is ANSI.
|
sl@0
|
38 |
* No supporting OS subroutines are required.
|
sl@0
|
39 |
*
|
sl@0
|
40 |
*
|
sl@0
|
41 |
*/
|
sl@0
|
42 |
|
sl@0
|
43 |
|
sl@0
|
44 |
|
sl@0
|
45 |
#include <stdlib.h>
|
sl@0
|
46 |
|
sl@0
|
47 |
/**
|
sl@0
|
48 |
Return absolute value of integer parameter.
|
sl@0
|
49 |
@return The absolute value of n.
|
sl@0
|
50 |
@param i Integer value.
|
sl@0
|
51 |
*/
|
sl@0
|
52 |
EXPORT_C int abs (int i)
|
sl@0
|
53 |
{
|
sl@0
|
54 |
return (i < 0) ? -i : i;
|
sl@0
|
55 |
}
|