1*f94f3cafSderaadt /* $OpenBSD: fabs.c,v 1.10 2013/11/13 15:21:48 deraadt Exp $ */
2aeb694e3Smartynas /*
3aeb694e3Smartynas * Copyright (c) 2008 Martynas Venckus <martynas@openbsd.org>
4aeb694e3Smartynas *
5aeb694e3Smartynas * Permission to use, copy, modify, and distribute this software for any
6aeb694e3Smartynas * purpose with or without fee is hereby granted, provided that the above
7aeb694e3Smartynas * copyright notice and this permission notice appear in all copies.
8aeb694e3Smartynas *
9aeb694e3Smartynas * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10aeb694e3Smartynas * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11aeb694e3Smartynas * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12aeb694e3Smartynas * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13aeb694e3Smartynas * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14aeb694e3Smartynas * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15aeb694e3Smartynas * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16aeb694e3Smartynas */
17aeb694e3Smartynas
18aeb694e3Smartynas #include <sys/types.h>
19aeb694e3Smartynas #include <machine/ieee.h>
20*f94f3cafSderaadt #include <math.h>
21aeb694e3Smartynas
22aeb694e3Smartynas /*
23aeb694e3Smartynas * fabs(d) returns the absolute value of d.
24aeb694e3Smartynas */
25aeb694e3Smartynas double
fabs(double d)26aeb694e3Smartynas fabs(double d)
27aeb694e3Smartynas {
28aeb694e3Smartynas struct ieee_double *p = (struct ieee_double *)&d;
29aeb694e3Smartynas
30aeb694e3Smartynas p->dbl_sign = 0;
31aeb694e3Smartynas
32aeb694e3Smartynas return(d);
33aeb694e3Smartynas }
34aeb694e3Smartynas
352fbf033eSmartynas __strong_alias(fabsl, fabs);
36