1/**************************************************************** 2 3The author of this software is David M. Gay. 4 5Copyright (C) 1998, 2001 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 David M. Gay (dmg at acm dot org, 30 * with " at " changed at "@" and " dot " changed to "."). */ 31 32#include "gdtoaimp.h" 33#include <stdio.h> 34#include <stdlib.h> 35 36 static char ibuf[2048]; 37 38#define U (unsigned long) 39 40 static void 41#ifdef KR_headers 42dshow(what, d) char *what; double d; 43#else 44dshow(char *what, double d) 45#endif 46{ 47 char buf[32]; 48 g_dfmt(buf, &d, 0, sizeof(buf)); 49 printf("%s = #%lx %lx = %s\n", what, 50 U ((ULong*)&d)[_0], U ((ULong*)&d)[_1], buf); 51 } 52 53 int 54main(Void) 55{ 56 /* Input: one number per line */ 57 58 char *s, *se, *se1; 59 int i, j; 60 double dd[2], dd1, dd2; 61 static char cfmt[] = "%s consumes %d bytes and returns %d\n"; 62 63 while( (s = fgets(ibuf, sizeof(ibuf), stdin)) !=0) { 64 while(*s <= ' ') 65 if (!*s++) 66 continue; 67 printf("\nInput: %s", ibuf); 68 i = strtodI(ibuf, &se, dd); 69 printf(cfmt, "strtodI", (int)(se-ibuf), i); 70 dshow("dd[0]", dd[0]); 71 dshow("dd[1]", dd[1]); 72 printf("\n"); 73 j = strtoId(ibuf, &se1, &dd1, &dd2); 74 if (j != i || se != se1 75 || dd[0] != dd1 || dd[1] != dd2) { 76 printf(cfmt, "**** strtoId", (int)(se-ibuf), j); 77 dshow("dd1", dd1); 78 dshow("dd2", dd2); 79 } 80 } 81 return 0; 82 } 83