/****************************************************************12The author of this software is David M. Gay.34Copyright (C) 1998, 2000 by Lucent Technologies5All Rights Reserved67Permission to use, copy, modify, and distribute this software and8its documentation for any purpose and without fee is hereby9granted, provided that the above copyright notice appear in all10copies and that both that the copyright notice and this11permission notice and warranty disclaimer appear in supporting12documentation, and that the name of Lucent or any of its entities13not be used in advertising or publicity pertaining to14distribution of the software without specific, written prior15permission.1617LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,18INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.19IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY20SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES21WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER22IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,23ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF24THIS SOFTWARE.2526****************************************************************/2728/* Please send bug reports to David M. Gay (dmg at acm dot org,29* with " at " changed at "@" and " dot " changed to "."). */3031#include "gdtoaimp.h"3233#undef _034#undef _13536/* one or the other of IEEE_MC68k or IEEE_8087 should be #defined */3738#ifdef IEEE_MC68k39#define _0 040#define _1 141#define _2 242#define _3 343#define _4 444#endif45#ifdef IEEE_808746#define _0 447#define _1 348#define _2 249#define _3 150#define _4 051#endif5253int54#ifdef KR_headers55strtopx(s, sp, V) CONST char *s; char **sp; void *V;56#else57strtopx(CONST char *s, char **sp, void *V)58#endif59{60static FPI fpi0 = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, SI };61ULong bits[2];62Long exp;63int k;64UShort *L = (UShort*)V;65#ifdef Honor_FLT_ROUNDS66#include "gdtoa_fltrnds.h"67#else68#define fpi &fpi069#endif7071k = strtodg(s, sp, fpi, &exp, bits);72switch(k & STRTOG_Retmask) {73case STRTOG_NoNumber:74case STRTOG_Zero:75L[0] = L[1] = L[2] = L[3] = L[4] = 0;76break;7778case STRTOG_Denormal:79L[_0] = 0;80goto normal_bits;8182case STRTOG_Normal:83case STRTOG_NaNbits:84L[_0] = exp + 0x3fff + 63;85normal_bits:86L[_4] = (UShort)bits[0];87L[_3] = (UShort)(bits[0] >> 16);88L[_2] = (UShort)bits[1];89L[_1] = (UShort)(bits[1] >> 16);90break;9192case STRTOG_Infinite:93L[_0] = 0x7fff;94L[_1] = 0x8000;95L[_2] = L[_3] = L[_4] = 0;96break;9798case STRTOG_NaN:99L[0] = ldus_QNAN0;100L[1] = ldus_QNAN1;101L[2] = ldus_QNAN2;102L[3] = ldus_QNAN3;103L[4] = ldus_QNAN4;104}105if (k & STRTOG_Neg)106L[_0] |= 0x8000;107return k;108}109110111