Last change
on this file since 543 was
444,
checked in by satin@…, 6 years ago
|
add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc
|
File size:
1.1 KB
|
Line | |
---|
1 | |
---|
2 | /* @(#)z_frexpf.c 1.0 98/08/13 */ |
---|
3 | /****************************************************************** |
---|
4 | * frexp |
---|
5 | * |
---|
6 | * Input: |
---|
7 | * d - floating point value |
---|
8 | * exp - exponent value |
---|
9 | * |
---|
10 | * Output: |
---|
11 | * A floating point value in the range [0.5, 1). |
---|
12 | * |
---|
13 | * Description: |
---|
14 | * This routine breaks a floating point value into a number f and |
---|
15 | * an exponent exp such that d = f * 2 ^ exp. |
---|
16 | * |
---|
17 | *****************************************************************/ |
---|
18 | |
---|
19 | #include "fdlibm.h" |
---|
20 | #include "zmath.h" |
---|
21 | |
---|
22 | float frexpf (float d, int *exp) |
---|
23 | { |
---|
24 | float f; |
---|
25 | __int32_t wf, wd; |
---|
26 | |
---|
27 | /* Check for special values. */ |
---|
28 | switch (numtestf (d)) |
---|
29 | { |
---|
30 | case NAN: |
---|
31 | case INF: |
---|
32 | errno = EDOM; |
---|
33 | case 0: |
---|
34 | *exp = 0; |
---|
35 | return (d); |
---|
36 | } |
---|
37 | |
---|
38 | GET_FLOAT_WORD (wd, d); |
---|
39 | |
---|
40 | /* Get the exponent. */ |
---|
41 | *exp = ((wd & 0x7f800000) >> 23) - 126; |
---|
42 | |
---|
43 | /* Get the mantissa. */ |
---|
44 | wf = wd & 0x7fffff; |
---|
45 | wf |= 0x3f000000; |
---|
46 | |
---|
47 | SET_FLOAT_WORD (f, wf); |
---|
48 | |
---|
49 | return (f); |
---|
50 | } |
---|
51 | |
---|
52 | #ifdef _DOUBLE_IS_32BITS |
---|
53 | |
---|
54 | double frexp (double x, int *exp) |
---|
55 | { |
---|
56 | return (double) frexpf ((float) x, exp); |
---|
57 | } |
---|
58 | |
---|
59 | #endif /* defined(_DOUBLE_IS_32BITS) */ |
---|
Note: See
TracBrowser
for help on using the repository browser.