Cygwin: mmap: allow remapping part of an existing anonymous mapping
[newlib-cygwin.git] / newlib / libc / stdlib / __adjust.c
blobab6f125b9311499bc3b05a4c51a0373fe20dfb76
1 /*
2 * return (*acc) scaled by 10**dexp.
3 */
5 #include <_ansi.h>
6 #include <reent.h>
7 #include "std.h"
9 #define abs(x) (((x) < 0) ? -(x) : (x))
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 */
20 double r;
22 if (dexp > MAXE)
24 _REENT_ERRNO(ptr) = ERANGE;
25 return (sign) ? -HUGE_VAL : HUGE_VAL;
27 else if (dexp < MINE)
29 _REENT_ERRNO(ptr) = ERANGE;
30 return 0.0;
33 r = *acc;
34 if (sign)
35 r = -r;
36 if (dexp == 0)
37 return r;
39 if (dexp < 0)
40 return r / __exp10 (abs (dexp));
41 else
42 return r * __exp10 (dexp);