1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericopenlibs/cstdlib/LSTDLIB/ABS.C Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,55 @@
1.4 +/*
1.5 +* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +* FUNCTION
1.19 +* <<abs>>---integer absolute value (magnitude)
1.20 +* INDEX
1.21 +* abs
1.22 +* ANSI_SYNOPSIS
1.23 +* #include <stdlib.h>
1.24 +* int abs(int <[i]>);
1.25 +* TRAD_SYNOPSIS
1.26 +* #include <stdlib.h>
1.27 +* int abs(<[i]>)
1.28 +* int <[i]>;
1.29 +* <<abs>> returns
1.30 +* @tex
1.31 +* $|x|$,
1.32 +* @end tex
1.33 +* the absolute value of <[i]> (also called the magnitude
1.34 +* of <[i]>). That is, if <[i]> is negative, the result is the opposite
1.35 +* of <[i]>, but if <[i]> is nonnegative the result is <[i]>.
1.36 +* The similar function <<labs>> uses and returns <<long>> rather than <<int>> values.
1.37 +* RETURNS
1.38 +* The result is a nonnegative integer.
1.39 +* PORTABILITY
1.40 +* <<abs>> is ANSI.
1.41 +* No supporting OS subroutines are required.
1.42 +*
1.43 +*
1.44 +*/
1.45 +
1.46 +
1.47 +
1.48 +#include <stdlib.h>
1.49 +
1.50 +/**
1.51 +Return absolute value of integer parameter.
1.52 +@return The absolute value of n.
1.53 +@param i Integer value.
1.54 +*/
1.55 +EXPORT_C int abs (int i)
1.56 +{
1.57 + return (i < 0) ? -i : i;
1.58 +}