strtord.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /****************************************************************
  2. The author of this software is David M. Gay.
  3. Copyright (C) 1998, 2000 by Lucent Technologies
  4. All Rights Reserved
  5. Permission to use, copy, modify, and distribute this software and
  6. its documentation for any purpose and without fee is hereby
  7. granted, provided that the above copyright notice appear in all
  8. copies and that both that the copyright notice and this
  9. permission notice and warranty disclaimer appear in supporting
  10. documentation, and that the name of Lucent or any of its entities
  11. not be used in advertising or publicity pertaining to
  12. distribution of the software without specific, written prior
  13. permission.
  14. LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  15. INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
  16. IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
  17. SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  18. WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
  19. IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  20. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
  21. THIS SOFTWARE.
  22. ****************************************************************/
  23. /* Please send bug reports to David M. Gay (dmg at acm dot org,
  24. * with " at " changed at "@" and " dot " changed to "."). */
  25. #include "gdtoaimp.h"
  26. void
  27. #ifdef KR_headers
  28. ULtod(L, bits, exp, k) ULong *L; ULong *bits; Long exp; int k;
  29. #else
  30. ULtod(ULong *L, ULong *bits, Long exp, int k)
  31. #endif
  32. {
  33. switch(k & STRTOG_Retmask) {
  34. case STRTOG_NoNumber:
  35. case STRTOG_Zero:
  36. L[0] = L[1] = 0;
  37. break;
  38. case STRTOG_Denormal:
  39. L[_1] = bits[0];
  40. L[_0] = bits[1];
  41. break;
  42. case STRTOG_Normal:
  43. case STRTOG_NaNbits:
  44. L[_1] = bits[0];
  45. L[_0] = (bits[1] & ~0x100000) | ((exp + 0x3ff + 52) << 20);
  46. break;
  47. case STRTOG_NoMemory:
  48. errno = ERANGE;
  49. /* FALLTHROUGH */
  50. case STRTOG_Infinite:
  51. L[_0] = 0x7ff00000;
  52. L[_1] = 0;
  53. break;
  54. case STRTOG_NaN:
  55. L[0] = d_QNAN0;
  56. L[1] = d_QNAN1;
  57. }
  58. if (k & STRTOG_Neg)
  59. L[_0] |= 0x80000000L;
  60. }