Rev 4872 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4349 | Serge | 1 | /* sf_frexp.c -- float version of s_frexp.c. |
2 | * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
||
3 | */ |
||
4 | |||
5 | /* |
||
6 | * ==================================================== |
||
7 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
||
8 | * |
||
9 | * Developed at SunPro, a Sun Microsystems, Inc. business. |
||
10 | * Permission to use, copy, modify, and distribute this |
||
11 | * software is freely granted, provided that this notice |
||
12 | * is preserved. |
||
13 | * ==================================================== |
||
14 | */ |
||
15 | |||
16 | #include "fdlibm.h" |
||
17 | |||
18 | #ifdef __STDC__ |
||
19 | static const float |
||
20 | #else |
||
21 | static float |
||
22 | #endif |
||
23 | two25 = 3.3554432000e+07; /* 0x4c000000 */ |
||
24 | |||
25 | #ifdef __STDC__ |
||
26 | float frexpf(float x, int *eptr) |
||
27 | #else |
||
28 | float frexpf(x, eptr) |
||
29 | float x; int *eptr; |
||
30 | #endif |
||
31 | { |
||
32 | __int32_t hx, ix; |
||
33 | GET_FLOAT_WORD(hx,x); |
||
34 | ix = 0x7fffffff&hx; |
||
35 | *eptr = 0; |
||
36 | if(!FLT_UWORD_IS_FINITE(ix)||FLT_UWORD_IS_ZERO(ix)) return x; /* 0,inf,nan */ |
||
37 | if (FLT_UWORD_IS_SUBNORMAL(ix)) { /* subnormal */ |
||
38 | x *= two25; |
||
39 | GET_FLOAT_WORD(hx,x); |
||
40 | ix = hx&0x7fffffff; |
||
41 | *eptr = -25; |
||
42 | } |
||
43 | *eptr += (ix>>23)-126; |
||
44 | hx = (hx&0x807fffff)|0x3f000000; |
||
45 | SET_FLOAT_WORD(x,hx); |
||
46 | return x; |
||
47 | } |
||
48 | |||
49 | #ifdef _DOUBLE_IS_32BITS |
||
50 | |||
51 | #ifdef __STDC__ |
||
52 | double frexp(double x, int *eptr) |
||
53 | #else |
||
54 | double frexp(x, eptr) |
||
55 | double x; int *eptr; |
||
56 | #endif |
||
57 | { |
||
58 | return (double) frexpf((float) x, eptr); |
||
59 | } |
||
60 | |||
61 | #endif /* defined(_DOUBLE_IS_32BITS) */ |