xref: /freebsd/lib/libc/arm/gen/fabs.c (revision 559a218c9b257775fb249b67945fe4a05b7a6b9f)
12357939bSOlivier Houchard /*	$NetBSD: fabs.c,v 1.2 2002/05/26 11:48:01 wiz Exp $	*/
22357939bSOlivier Houchard 
3*df57947fSPedro F. Giffuni /*-
4*df57947fSPedro F. Giffuni  * SPDX-License-Identifier: BSD-4-Clause
5*df57947fSPedro F. Giffuni  *
62357939bSOlivier Houchard  * Copyright (c) 1996 Mark Brinicombe
72357939bSOlivier Houchard  *
82357939bSOlivier Houchard  * Redistribution and use in source and binary forms, with or without
92357939bSOlivier Houchard  * modification, are permitted provided that the following conditions
102357939bSOlivier Houchard  * are met:
112357939bSOlivier Houchard  * 1. Redistributions of source code must retain the above copyright
122357939bSOlivier Houchard  *    notice, this list of conditions and the following disclaimer.
132357939bSOlivier Houchard  * 2. Redistributions in binary form must reproduce the above copyright
142357939bSOlivier Houchard  *    notice, this list of conditions and the following disclaimer in the
152357939bSOlivier Houchard  *    documentation and/or other materials provided with the distribution.
162357939bSOlivier Houchard  * 3. All advertising materials mentioning features or use of this software
172357939bSOlivier Houchard  *    must display the following acknowledgement:
182357939bSOlivier Houchard  *	This product includes software developed by Mark Brinicombe
192357939bSOlivier Houchard  * 4. Neither the name of the University nor the names of its contributors
202357939bSOlivier Houchard  *    may be used to endorse or promote products derived from this software
212357939bSOlivier Houchard  *    without specific prior written permission.
222357939bSOlivier Houchard  *
232357939bSOlivier Houchard  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
242357939bSOlivier Houchard  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
252357939bSOlivier Houchard  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
262357939bSOlivier Houchard  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
272357939bSOlivier Houchard  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
282357939bSOlivier Houchard  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
292357939bSOlivier Houchard  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
302357939bSOlivier Houchard  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
312357939bSOlivier Houchard  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
322357939bSOlivier Houchard  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
332357939bSOlivier Houchard  * SUCH DAMAGE.
342357939bSOlivier Houchard  */
352357939bSOlivier Houchard 
362357939bSOlivier Houchard /*
372357939bSOlivier Houchard  * fabs(x) returns the absolute value of x.
382357939bSOlivier Houchard  */
392357939bSOlivier Houchard double
fabs(double x)402357939bSOlivier Houchard fabs(double x)
412357939bSOlivier Houchard {
422357939bSOlivier Houchard 	if (x < 0)
432357939bSOlivier Houchard 		x = -x;
442357939bSOlivier Houchard 	return(x);
452357939bSOlivier Houchard }
46