1/* $NetBSD: strtoIdd.c,v 1.1.1.1 2006/01/25 15:18:49 kleink Exp $ */ 2 3/**************************************************************** 4 5The author of this software is David M. Gay. 6 7Copyright (C) 1998 by Lucent Technologies 8All Rights Reserved 9 10Permission to use, copy, modify, and distribute this software and 11its documentation for any purpose and without fee is hereby 12granted, provided that the above copyright notice appear in all 13copies and that both that the copyright notice and this 14permission notice and warranty disclaimer appear in supporting 15documentation, and that the name of Lucent or any of its entities 16not be used in advertising or publicity pertaining to 17distribution of the software without specific, written prior 18permission. 19 20LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 21INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. 22IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY 23SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 24WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER 25IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 26ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF 27THIS SOFTWARE. 28 29****************************************************************/ 30 31/* Please send bug reports to David M. Gay (dmg at acm dot org, 32 * with " at " changed at "@" and " dot " changed to "."). */ 33 34#include "gdtoaimp.h" 35 36 int 37#ifdef KR_headers 38strtoIdd(s, sp, f0, f1) CONST char *s; char **sp; double *f0, *f1; 39#else 40strtoIdd(CONST char *s, char **sp, double *f0, double *f1) 41#endif 42{ 43#ifdef Sudden_Underflow 44 static FPI fpi = { 106, 1-1023, 2046-1023-106+1, 1, 1 }; 45#else 46 static FPI fpi = { 106, 1-1023-53+1, 2046-1023-106+1, 1, 0 }; 47#endif 48 Long exp[2]; 49 Bigint *B[2]; 50 int k, rv[2]; 51 52 B[0] = Balloc(2); 53 if (B[0] == NULL) 54 return STRTOG_NoMemory; 55 B[0]->wds = 4; 56 k = strtoIg(s, sp, &fpi, exp, B, rv); 57 if (k == STRTOG_NoMemory) 58 return k; 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