1 /* @(#)s_frexp.c 5.1 93/09/24 */
3 * ====================================================
4 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
6 * Developed at SunPro, a Sun Microsystems, Inc. business.
7 * Permission to use, copy, modify, and distribute this
8 * software is freely granted, provided that this notice
10 * ====================================================
13 #include <sys/cdefs.h>
14 __FBSDID("$FreeBSD$");
18 * x = frexp(arg,&exp);
19 * return a double fp quantity x such that 0.5 <= |x| <1.0
20 * and the corresponding binary exponent "exp". That is
22 * If arg is inf, 0.0, or NaN, then frexp(arg,&exp) returns arg
29 #include "math_private.h"
32 two54 = 1.80143985094819840000e+16; /* 0x43500000, 0x00000000 */
35 frexp(double x, int *eptr)
38 EXTRACT_WORDS(hx,lx,x);
41 if(ix>=0x7ff00000||((ix|lx)==0)) return x; /* 0,inf,nan */
42 if (ix<0x00100000) { /* subnormal */
48 *eptr += (ix>>20)-1022;
49 hx = (hx&0x800fffff)|0x3fe00000;
54 #if (LDBL_MANT_DIG == 53)
55 __weak_reference(frexp, frexpl);