/** @file\r
\r
- Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2012 - 2014, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials are licensed and made available under\r
the terms and conditions of the BSD License that accompanies this distribution.\r
The full text of the license may be found at\r
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF\r
THIS SOFTWARE.\r
\r
-\r
Please send bug reports to David M. Gay (dmg at acm dot org,\r
with " at " changed at "@" and " dot " changed to ".").\r
\r
};\r
\r
Bigint *\r
-#ifdef KR_headers\r
-increment(b) Bigint *b;\r
-#else\r
increment(Bigint *b)\r
-#endif\r
{\r
ULong *x, *xe;\r
Bigint *b1;\r
}\r
\r
int\r
-#ifdef KR_headers\r
-decrement(b) Bigint *b;\r
-#else\r
decrement(Bigint *b)\r
-#endif\r
{\r
ULong *x, *xe;\r
#ifdef Pack_16\r
}\r
\r
static int\r
-#ifdef KR_headers\r
-all_on(b, n) CONST Bigint *b; int n;\r
-#else\r
all_on(CONST Bigint *b, int n)\r
-#endif\r
{\r
CONST ULong *x, *xe;\r
\r
}\r
\r
Bigint *\r
-#ifdef KR_headers\r
-set_ones(b, n) Bigint *b; int n;\r
-#else\r
set_ones(Bigint *b, int n)\r
-#endif\r
{\r
int k;\r
ULong *x, *xe;\r
}\r
\r
static int\r
-rvOK\r
-#ifdef KR_headers\r
- (d, fpi, expt, bits, exact, rd, irv)\r
- double d; CONST FPI *fpi; Long *expt; ULong *bits; int exact, rd, *irv;\r
-#else\r
- (double d, CONST FPI *fpi, Long *expt, ULong *bits, int exact, int rd, int *irv)\r
-#endif\r
+rvOK (\r
+ double d, CONST FPI *fpi, Long *expt, ULong *bits, int exact, int rd, int *irv\r
+)\r
{\r
Bigint *b;\r
ULong carry, inex, lostbits;\r
return rv;\r
}\r
\r
-#ifndef VAX\r
static int\r
-#ifdef KR_headers\r
-mantbits(d) double d;\r
-#else\r
mantbits(double d)\r
-#endif\r
{\r
ULong L;\r
-#ifdef VAX\r
- L = word1(d) << 16 | word1(d) >> 16;\r
- if (L)\r
-#else\r
if ( (L = word1(d)) !=0)\r
-#endif\r
return P - lo0bits(&L);\r
-#ifdef VAX\r
- L = word0(d) << 16 | word0(d) >> 16 | Exp_msk11;\r
-#else\r
L = word0(d) | Exp_msk1;\r
-#endif\r
return P - 32 - lo0bits(&L);\r
}\r
-#endif /* !VAX */\r
\r
int\r
-strtodg\r
-#ifdef KR_headers\r
- (s00, se, fpi, expt, bits)\r
- CONST char *s00; char **se; CONST FPI *fpi; Long *expt; ULong *bits;\r
-#else\r
- (CONST char *s00, char **se, CONST FPI *fpi, Long *expt, ULong *bits)\r
-#endif\r
+strtodg (\r
+ CONST char *s00, char **se, CONST FPI *fpi, Long *expt, ULong *bits\r
+)\r
{\r
- int abe, abits, asub;\r
+ int abe = 0, abits = 0, asub;\r
int bb0, bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, decpt, denorm;\r
int dsign, e, e1, e2, emin, esign, finished, i, inex, irv;\r
int j, k, nbits, nd, nd0, nf, nz, nz0, rd, rvbits, rve, rve1, sign;\r
}\r
else if (e > 0) {\r
if (e <= Ten_pmax) {\r
-#ifdef VAX\r
- goto vax_ovfl_check;\r
-#else\r
i = fivesbits[e] + mantbits(dval(rv)) <= P;\r
/* rv = */ rounded_product(dval(rv), tens[e]);\r
if (rvOK(dval(rv), fpi, expt, bits, i, rd, &irv))\r
goto ret;\r
e1 -= e;\r
goto rv_notOK;\r
-#endif\r
}\r
i = DBL_DIG - nd;\r
if (e <= Ten_pmax + i) {\r
e2 = e - i;\r
e1 -= i;\r
dval(rv) *= tens[i];\r
-#ifdef VAX\r
- /* VAX exponent range is so narrow we must\r
- * worry about overflow here...\r
- */\r
- vax_ovfl_check:\r
- dval(adj) = dval(rv);\r
- word0(adj) -= P*Exp_msk1;\r
- /* adj = */ rounded_product(dval(adj), tens[e2]);\r
- if ((word0(adj) & Exp_mask)\r
- > Exp_msk1*(DBL_MAX_EXP+Bias-1-P))\r
- goto rv_notOK;\r
- word0(adj) += P*Exp_msk1;\r
- dval(rv) = dval(adj);\r
-#else\r
/* rv = */ rounded_product(dval(rv), tens[e2]);\r
-#endif\r
if (rvOK(dval(rv), fpi, expt, bits, 0, rd, &irv))\r
goto ret;\r
e1 -= e2;\r
dval(rv) *= tinytens[j];\r
}\r
}\r
-#ifdef IBM\r
- /* e2 is a correction to the (base 2) exponent of the return\r
- * value, reflecting adjustments above to avoid overflow in the\r
- * native arithmetic. For native IBM (base 16) arithmetic, we\r
- * must multiply e2 by 4 to change from base 16 to 2.\r
- */\r
- e2 <<= 2;\r
-#endif\r
rvb = d2b(dval(rv), &rve, &rvbits); /* rv = rvb * 2^rve */\r
if (rvb == NULL)\r
return STRTOG_NoMemory;\r
inex = STRTOG_Inexlo;\r
}\r
if (dval(adj) < 2147483647.) {\r
- L = (INT32)adj0;\r
+ L = (Long)adj0;\r
adj0 -= L;\r
switch(rd) {\r
case 0:\r
break;\r
case 2:\r
if (!asub && adj0 > 0.) {\r
- inc_L:\r
+inc_L:\r
L++;\r
inex = STRTOG_Inexact - inex;\r
}\r