strtoIdd.c revision 112158
1112158Sdas/****************************************************************
2112158Sdas
3112158SdasThe author of this software is David M. Gay.
4112158Sdas
5112158SdasCopyright (C) 1998 by Lucent Technologies
6112158SdasAll Rights Reserved
7112158Sdas
8112158SdasPermission to use, copy, modify, and distribute this software and
9112158Sdasits documentation for any purpose and without fee is hereby
10112158Sdasgranted, provided that the above copyright notice appear in all
11112158Sdascopies and that both that the copyright notice and this
12112158Sdaspermission notice and warranty disclaimer appear in supporting
13112158Sdasdocumentation, and that the name of Lucent or any of its entities
14112158Sdasnot be used in advertising or publicity pertaining to
15112158Sdasdistribution of the software without specific, written prior
16112158Sdaspermission.
17112158Sdas
18112158SdasLUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
19112158SdasINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
20112158SdasIN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
21112158SdasSPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
22112158SdasWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
23112158SdasIN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
24112158SdasARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
25112158SdasTHIS SOFTWARE.
26112158Sdas
27112158Sdas****************************************************************/
28112158Sdas
29112158Sdas/* Please send bug reports to
30112158Sdas	David M. Gay
31112158Sdas	Bell Laboratories, Room 2C-463
32112158Sdas	600 Mountain Avenue
33112158Sdas	Murray Hill, NJ 07974-0636
34112158Sdas	U.S.A.
35112158Sdas	dmg@bell-labs.com
36112158Sdas */
37112158Sdas
38112158Sdas#include "gdtoaimp.h"
39112158Sdas
40112158Sdas int
41112158Sdas#ifdef KR_headers
42112158SdasstrtoIdd(s, sp, f0, f1) CONST char *s; char **sp; double *f0, *f1;
43112158Sdas#else
44112158SdasstrtoIdd(CONST char *s, char **sp, double *f0, double *f1)
45112158Sdas#endif
46112158Sdas{
47112158Sdas#ifdef Sudden_Underflow
48112158Sdas	static FPI fpi = { 106, 1-1023, 2046-1023-106+1, 1, 1 };
49112158Sdas#else
50112158Sdas	static FPI fpi = { 106, 1-1023-53+1, 2046-1023-106+1, 1, 0 };
51112158Sdas#endif
52112158Sdas	Long exp[2];
53112158Sdas	Bigint *B[2];
54112158Sdas	int k, rv[2];
55112158Sdas
56112158Sdas	B[0] = Balloc(2);
57112158Sdas	B[0]->wds = 4;
58112158Sdas	k = strtoIg(s, sp, &fpi, exp, B, rv);
59112158Sdas	ULtodd((ULong*)f0, B[0]->x, exp[0], rv[0]);
60112158Sdas	Bfree(B[0]);
61112158Sdas	if (B[1]) {
62112158Sdas		ULtodd((ULong*)f1, B[1]->x, exp[1], rv[1]);
63112158Sdas		Bfree(B[1]);
64112158Sdas		}
65112158Sdas	else {
66112158Sdas		((ULong*)f1)[0] = ((ULong*)f0)[0];
67112158Sdas		((ULong*)f1)[1] = ((ULong*)f0)[1];
68112158Sdas		((ULong*)f1)[2] = ((ULong*)f0)[2];
69112158Sdas		((ULong*)f1)[3] = ((ULong*)f0)[3];
70112158Sdas		}
71112158Sdas	return k;
72112158Sdas	}
73