Last change
on this file since 577 was
444,
checked in by satin@…, 6 years ago
|
add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc
|
File size:
691 bytes
|
Line | |
---|
1 | /* |
---|
2 | * return (*acc) scaled by 10**dexp. |
---|
3 | */ |
---|
4 | |
---|
5 | #include <_ansi.h> |
---|
6 | #include <reent.h> |
---|
7 | #include "std.h" |
---|
8 | |
---|
9 | #define abs(x) (((x) < 0) ? -(x) : (x)) |
---|
10 | |
---|
11 | double |
---|
12 | __adjust (struct _reent *ptr, |
---|
13 | double *acc, |
---|
14 | int dexp, |
---|
15 | int sign) |
---|
16 | /* *acc the 64 bit accumulator */ |
---|
17 | /* dexp decimal exponent */ |
---|
18 | /* sign sign flag */ |
---|
19 | { |
---|
20 | double r; |
---|
21 | |
---|
22 | if (dexp > MAXE) |
---|
23 | { |
---|
24 | ptr->_errno = ERANGE; |
---|
25 | return (sign) ? -HUGE_VAL : HUGE_VAL; |
---|
26 | } |
---|
27 | else if (dexp < MINE) |
---|
28 | { |
---|
29 | ptr->_errno = ERANGE; |
---|
30 | return 0.0; |
---|
31 | } |
---|
32 | |
---|
33 | r = *acc; |
---|
34 | if (sign) |
---|
35 | r = -r; |
---|
36 | if (dexp == 0) |
---|
37 | return r; |
---|
38 | |
---|
39 | if (dexp < 0) |
---|
40 | return r / __exp10 (abs (dexp)); |
---|
41 | else |
---|
42 | return r * __exp10 (dexp); |
---|
43 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.