]>
git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/ieee754/dbl-64/wordsize-64/s_frexp.c
b1d14354e05037c029cae989d044997273196ac7
1 /* Copyright (C) 2011-2020 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
21 #include <math_private.h>
22 #include <libm-alias-double.h>
25 * for non-zero, finite x
26 * x = frexp(arg,&exp);
27 * return a double fp quantity x such that 0.5 <= |x| <1.0
28 * and the corresponding binary exponent "exp". That is
30 * If arg is inf, 0.0, or NaN, then frexp(arg,&exp) returns arg
36 __frexp (double x
, int *eptr
)
39 EXTRACT_WORDS64 (ix
, x
);
40 int32_t ex
= 0x7ff & (ix
>> 52);
43 if (__glibc_likely (ex
!= 0x7ff && x
!= 0.0))
45 /* Not zero and finite. */
47 if (__glibc_unlikely (ex
== 0))
51 EXTRACT_WORDS64 (ix
, x
);
52 ex
= 0x7ff & (ix
>> 52);
56 ix
= (ix
& INT64_C (0x800fffffffffffff)) | INT64_C (0x3fe0000000000000);
57 INSERT_WORDS64 (x
, ix
);
60 /* Quiet signaling NaNs. */
66 libm_alias_double (__frexp
, frexp
)