/****************************************************************12The author of this software is David M. Gay.34Copyright (C) 2004 by David M. Gay.5All Rights Reserved6Based on material in the rest of /netlib/fp/gdota.tar.gz,7which is copyright (C) 1998, 2000 by Lucent Technologies.89Permission to use, copy, modify, and distribute this software and10its documentation for any purpose and without fee is hereby11granted, provided that the above copyright notice appear in all12copies and that both that the copyright notice and this13permission notice and warranty disclaimer appear in supporting14documentation, and that the name of Lucent or any of its entities15not be used in advertising or publicity pertaining to16distribution of the software without specific, written prior17permission.1819LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,20INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.21IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY22SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES23WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER24IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,25ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF26THIS SOFTWARE.2728****************************************************************/2930/* This is a variant of strtod that works on Intel ia32 systems */31/* with the default extended-precision arithmetic -- it does not */32/* require setting the precision control to 53 bits. */3334/* Please send bug reports to David M. Gay (dmg at acm dot org,35* with " at " changed at "@" and " dot " changed to "."). */3637#include "gdtoaimp.h"3839double40#ifdef KR_headers41strtod(s, sp) CONST char *s; char **sp;42#else43strtod(CONST char *s, char **sp)44#endif45{46static FPI fpi = { 53, 1-1023-53+1, 2046-1023-53+1, 1, SI };47ULong bits[2];48Long exp;49int k;50union { ULong L[2]; double d; } u;5152k = strtodg(s, sp, &fpi, &exp, bits);53switch(k & STRTOG_Retmask) {54case STRTOG_NoNumber:55case STRTOG_Zero:56u.L[0] = u.L[1] = 0;57break;5859case STRTOG_Normal:60u.L[_1] = bits[0];61u.L[_0] = (bits[1] & ~0x100000) | ((exp + 0x3ff + 52) << 20);62break;6364case STRTOG_Denormal:65u.L[_1] = bits[0];66u.L[_0] = bits[1];67break;6869case STRTOG_Infinite:70u.L[_0] = 0x7ff00000;71u.L[_1] = 0;72break;7374case STRTOG_NaN:75u.L[0] = d_QNAN0;76u.L[1] = d_QNAN1;77break;7879case STRTOG_NaNbits:80u.L[_0] = 0x7ff00000 | bits[1];81u.L[_1] = bits[0];82}83if (k & STRTOG_Neg)84u.L[_0] |= 0x80000000L;85return u.d;86}878889