1 /* Copyright (C) 2005-2022 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <https://www.gnu.org/licenses/>. */
24 __multc3 (long double a
, long double b
, long double c
, long double d
)
26 long double ac
, bd
, ad
, bc
, x
, y
;
36 if (isnan (x
) && isnan (y
))
38 /* Recover infinities that computed as NaN + iNaN. */
40 if (isinf (a
) || isinf (b
))
42 /* z is infinite. "Box" the infinity and change NaNs in
43 the other factor to 0. */
44 a
= copysignl (isinf (a
) ? 1 : 0, a
);
45 b
= copysignl (isinf (b
) ? 1 : 0, b
);
46 if (isnan (c
)) c
= copysignl (0, c
);
47 if (isnan (d
)) d
= copysignl (0, d
);
50 if (isinf (c
) || isinf (d
))
52 /* w is infinite. "Box" the infinity and change NaNs in
53 the other factor to 0. */
54 c
= copysignl (isinf (c
) ? 1 : 0, c
);
55 d
= copysignl (isinf (d
) ? 1 : 0, d
);
56 if (isnan (a
)) a
= copysignl (0, a
);
57 if (isnan (b
)) b
= copysignl (0, b
);
61 && (isinf (ac
) || isinf (bd
)
62 || isinf (ad
) || isinf (bc
)))
64 /* Recover infinities from overflow by changing NaNs to 0. */
65 if (isnan (a
)) a
= copysignl (0, a
);
66 if (isnan (b
)) b
= copysignl (0, b
);
67 if (isnan (c
)) c
= copysignl (0, c
);
68 if (isnan (d
)) d
= copysignl (0, d
);
73 x
= INFINITY
* (a
* c
- b
* d
);
74 y
= INFINITY
* (a
* d
+ b
* c
);