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