14bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes/**************************************************************** 24bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes 34bd97cee28dd815fff54fc97560be60d566c1fa5Elliott HughesThe author of this software is David M. Gay. 44bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes 54bd97cee28dd815fff54fc97560be60d566c1fa5Elliott HughesCopyright (C) 1998, 2000 by Lucent Technologies 64bd97cee28dd815fff54fc97560be60d566c1fa5Elliott HughesAll Rights Reserved 74bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes 84bd97cee28dd815fff54fc97560be60d566c1fa5Elliott HughesPermission to use, copy, modify, and distribute this software and 94bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughesits documentation for any purpose and without fee is hereby 104bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughesgranted, provided that the above copyright notice appear in all 114bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughescopies and that both that the copyright notice and this 124bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughespermission notice and warranty disclaimer appear in supporting 134bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughesdocumentation, and that the name of Lucent or any of its entities 144bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughesnot be used in advertising or publicity pertaining to 154bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughesdistribution of the software without specific, written prior 164bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughespermission. 174bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes 184bd97cee28dd815fff54fc97560be60d566c1fa5Elliott HughesLUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 194bd97cee28dd815fff54fc97560be60d566c1fa5Elliott HughesINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. 204bd97cee28dd815fff54fc97560be60d566c1fa5Elliott HughesIN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY 214bd97cee28dd815fff54fc97560be60d566c1fa5Elliott HughesSPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 224bd97cee28dd815fff54fc97560be60d566c1fa5Elliott HughesWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER 234bd97cee28dd815fff54fc97560be60d566c1fa5Elliott HughesIN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 244bd97cee28dd815fff54fc97560be60d566c1fa5Elliott HughesARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF 254bd97cee28dd815fff54fc97560be60d566c1fa5Elliott HughesTHIS SOFTWARE. 264bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes 274bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes****************************************************************/ 284bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes 294bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes/* Please send bug reports to David M. Gay (dmg at acm dot org, 304bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes * with " at " changed at "@" and " dot " changed to "."). */ 314bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes 324bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#include "gdtoaimp.h" 334bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes 344bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes void 354bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#ifdef KR_headers 364bd97cee28dd815fff54fc97560be60d566c1fa5Elliott HughesULtod(L, bits, exp, k) ULong *L; ULong *bits; Long exp; int k; 374bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#else 384bd97cee28dd815fff54fc97560be60d566c1fa5Elliott HughesULtod(ULong *L, ULong *bits, Long exp, int k) 394bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#endif 404bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes{ 414bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes switch(k & STRTOG_Retmask) { 424bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes case STRTOG_NoNumber: 434bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes case STRTOG_Zero: 444bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes L[0] = L[1] = 0; 454bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes break; 464bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes 474bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes case STRTOG_Denormal: 484bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes L[_1] = bits[0]; 494bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes L[_0] = bits[1]; 504bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes break; 514bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes 524bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes case STRTOG_Normal: 534bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes case STRTOG_NaNbits: 544bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes L[_1] = bits[0]; 554bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes L[_0] = (bits[1] & ~0x100000) | ((exp + 0x3ff + 52) << 20); 564bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes break; 574bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes 584bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes case STRTOG_NoMemory: 594bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes errno = ERANGE; 604bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes /* FALLTHROUGH */ 614bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes case STRTOG_Infinite: 624bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes L[_0] = 0x7ff00000; 634bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes L[_1] = 0; 644bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes break; 654bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes 664bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes case STRTOG_NaN: 674bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes L[0] = d_QNAN0; 684bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes L[1] = d_QNAN1; 694bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes } 704bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes if (k & STRTOG_Neg) 714bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes L[_0] |= 0x80000000L; 724bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes } 734bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes 744bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes int 754bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#ifdef KR_headers 764bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughesstrtord(s, sp, rounding, d) CONST char *s; char **sp; int rounding; double *d; 774bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#else 784bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughesstrtord(CONST char *s, char **sp, int rounding, double *d) 794bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#endif 804bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes{ 814bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes static FPI fpi0 = { 53, 1-1023-53+1, 2046-1023-53+1, 1, SI }; 824bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes FPI *fpi, fpi1; 834bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes ULong bits[2]; 844bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes Long exp; 854bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes int k; 864bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes 874bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes fpi = &fpi0; 884bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes if (rounding != FPI_Round_near) { 894bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes fpi1 = fpi0; 904bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes fpi1.rounding = rounding; 914bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes fpi = &fpi1; 924bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes } 934bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes k = strtodg(s, sp, fpi, &exp, bits); 944bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes ULtod((ULong*)d, bits, exp, k); 954bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes return k; 964bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes } 97