Replace FSF snail mail address with URLs.
[glibc.git] / sysdeps / sparc / sparc64 / soft-fp / qp_util.c
blobfd3043bb8e84e5d658e04ec4c00fb6fb0d5e0274
1 /* Software floating-point emulation.
2 Helper routine for _Qp_* routines.
3 Simulate exceptions using double arithmetics.
4 Copyright (C) 1999 Free Software Foundation, Inc.
5 This file is part of the GNU C Library.
6 Contributed by Jakub Jelinek (jj@ultra.linux.cz).
8 The GNU C Library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
13 The GNU C Library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public
19 License along with the GNU C Library; if not, see
20 <http://www.gnu.org/licenses/>. */
22 #include "soft-fp.h"
24 static unsigned long numbers [] = {
25 0x7fef000000000000UL, /* A huge double number */
26 0x0010100000000000UL, /* Very tiny number */
27 0x0010000000000000UL, /* Minimum normalized number */
28 0x0000000000000000UL, /* Zero */
31 double __Qp_handle_exceptions(int exceptions)
33 double d, *p = (double *)numbers;
34 if (exceptions & FP_EX_INVALID)
35 d = p[3]/p[3];
36 if (exceptions & FP_EX_OVERFLOW)
38 d = p[0] + p[0];
39 exceptions &= ~FP_EX_INEXACT;
41 if (exceptions & FP_EX_UNDERFLOW)
43 if (exceptions & FP_EX_INEXACT)
45 d = p[2] * p[2];
46 exceptions &= ~FP_EX_INEXACT;
48 else
49 d = p[1] - p[2];
51 if (exceptions & FP_EX_DIVZERO)
52 d = 1.0/p[3];
53 if (exceptions & FP_EX_INEXACT)
54 d = p[0] - p[2];
55 return d;