]>
Commit | Line | Data |
---|---|---|
3d4837df | 1 | /* Compute x * y + z as ternary operation. |
b168057a | 2 | Copyright (C) 2011-2015 Free Software Foundation, Inc. |
3d4837df UD |
3 | This file is part of the GNU C Library. |
4 | Contributed by David Flaherty <flaherty@linux.vnet.ibm.com>. | |
5 | ||
6 | The GNU C Library is free software; you can redistribute it and/or | |
7 | modify it under the terms of the GNU Lesser General Public | |
8 | License as published by the Free Software Foundation; either | |
9 | version 2.1 of the License, or (at your option) any later version. | |
10 | ||
11 | The GNU C Library is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | Lesser General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU Lesser General Public | |
59ba27a6 PE |
17 | License along with the GNU C Library; if not, see |
18 | <http://www.gnu.org/licenses/>. */ | |
3d4837df UD |
19 | |
20 | #include <math.h> | |
21 | #include <math_ldbl_opt.h> | |
22 | ||
23 | long double | |
24 | __fmal (long double x, long double y, long double z) | |
25 | { | |
26 | /* An IBM long double 128 is really just 2 IEEE64 doubles, and in | |
27 | * the case of inf/nan only the first double counts. So we use the | |
28 | * (double) cast to avoid any data movement. */ | |
29 | if ((finite ((double)x) && finite ((double)y)) && isinf ((double)z)) | |
30 | return (z); | |
31 | ||
c60d3bf2 JM |
32 | /* If z is zero and x are y are nonzero, compute the result |
33 | as x * y to avoid the wrong sign of a zero result if x * y | |
34 | underflows to 0. */ | |
35 | if (z == 0 && x != 0 && y != 0) | |
36 | return x * y; | |
37 | ||
3d4837df UD |
38 | return (x * y) + z; |
39 | } | |
a109996e | 40 | #if IS_IN (libm) |
3d4837df UD |
41 | long_double_symbol (libm, __fmal, fmal); |
42 | #else | |
43 | long_double_symbol (libc, __fmal, fmal); | |
44 | #endif |