sl@0: /* sl@0: * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * FUNCTION sl@0: * <>---integer absolute value (magnitude) sl@0: * INDEX sl@0: * abs sl@0: * ANSI_SYNOPSIS sl@0: * #include sl@0: * int abs(int <[i]>); sl@0: * TRAD_SYNOPSIS sl@0: * #include sl@0: * int abs(<[i]>) sl@0: * int <[i]>; sl@0: * <> returns sl@0: * @tex sl@0: * $|x|$, sl@0: * @end tex sl@0: * the absolute value of <[i]> (also called the magnitude sl@0: * of <[i]>). That is, if <[i]> is negative, the result is the opposite sl@0: * of <[i]>, but if <[i]> is nonnegative the result is <[i]>. sl@0: * The similar function <> uses and returns <> rather than <> values. sl@0: * RETURNS sl@0: * The result is a nonnegative integer. sl@0: * PORTABILITY sl@0: * <> is ANSI. sl@0: * No supporting OS subroutines are required. sl@0: * sl@0: * sl@0: */ sl@0: sl@0: sl@0: sl@0: #include sl@0: sl@0: /** sl@0: Return absolute value of integer parameter. sl@0: @return The absolute value of n. sl@0: @param i Integer value. sl@0: */ sl@0: EXPORT_C int abs (int i) sl@0: { sl@0: return (i < 0) ? -i : i; sl@0: }