strtoIdd.c revision 112158
1/**************************************************************** 2 3The author of this software is David M. Gay. 4 5Copyright (C) 1998 by Lucent Technologies 6All Rights Reserved 7 8Permission to use, copy, modify, and distribute this software and 9its documentation for any purpose and without fee is hereby 10granted, provided that the above copyright notice appear in all 11copies and that both that the copyright notice and this 12permission notice and warranty disclaimer appear in supporting 13documentation, and that the name of Lucent or any of its entities 14not be used in advertising or publicity pertaining to 15distribution of the software without specific, written prior 16permission. 17 18LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 19INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. 20IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY 21SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 22WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER 23IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 24ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF 25THIS SOFTWARE. 26 27****************************************************************/ 28 29/* Please send bug reports to 30 David M. Gay 31 Bell Laboratories, Room 2C-463 32 600 Mountain Avenue 33 Murray Hill, NJ 07974-0636 34 U.S.A. 35 dmg@bell-labs.com 36 */ 37 38#include "gdtoaimp.h" 39 40 int 41#ifdef KR_headers 42strtoIdd(s, sp, f0, f1) CONST char *s; char **sp; double *f0, *f1; 43#else 44strtoIdd(CONST char *s, char **sp, double *f0, double *f1) 45#endif 46{ 47#ifdef Sudden_Underflow 48 static FPI fpi = { 106, 1-1023, 2046-1023-106+1, 1, 1 }; 49#else 50 static FPI fpi = { 106, 1-1023-53+1, 2046-1023-106+1, 1, 0 }; 51#endif 52 Long exp[2]; 53 Bigint *B[2]; 54 int k, rv[2]; 55 56 B[0] = Balloc(2); 57 B[0]->wds = 4; 58 k = strtoIg(s, sp, &fpi, exp, B, rv); 59 ULtodd((ULong*)f0, B[0]->x, exp[0], rv[0]); 60 Bfree(B[0]); 61 if (B[1]) { 62 ULtodd((ULong*)f1, B[1]->x, exp[1], rv[1]); 63 Bfree(B[1]); 64 } 65 else { 66 ((ULong*)f1)[0] = ((ULong*)f0)[0]; 67 ((ULong*)f1)[1] = ((ULong*)f0)[1]; 68 ((ULong*)f1)[2] = ((ULong*)f0)[2]; 69 ((ULong*)f1)[3] = ((ULong*)f0)[3]; 70 } 71 return k; 72 } 73