gdtoa.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /****************************************************************
  2. The author of this software is David M. Gay.
  3. Copyright (C) 1998 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. #ifndef GDTOA_H_INCLUDED
  26. #define GDTOA_H_INCLUDED
  27. #include "arith.h"
  28. #include <stddef.h> /* for size_t */
  29. #ifndef Long
  30. #define Long int
  31. #endif
  32. #ifndef ULong
  33. typedef unsigned Long ULong;
  34. #endif
  35. #ifndef UShort
  36. typedef unsigned short UShort;
  37. #endif
  38. #ifndef ANSI
  39. #ifdef KR_headers
  40. #define ANSI(x) ()
  41. #define Void /*nothing*/
  42. #else
  43. #define ANSI(x) x
  44. #define Void void
  45. #endif
  46. #endif /* ANSI */
  47. #ifndef CONST
  48. #ifdef KR_headers
  49. #define CONST /* blank */
  50. #else
  51. #define CONST const
  52. #endif
  53. #endif /* CONST */
  54. enum { /* return values from strtodg */
  55. STRTOG_Zero = 0x000,
  56. STRTOG_Normal = 0x001,
  57. STRTOG_Denormal = 0x002,
  58. STRTOG_Infinite = 0x003,
  59. STRTOG_NaN = 0x004,
  60. STRTOG_NaNbits = 0x005,
  61. STRTOG_NoNumber = 0x006,
  62. STRTOG_NoMemory = 0x007,
  63. STRTOG_Retmask = 0x00f,
  64. /* The following may be or-ed into one of the above values. */
  65. STRTOG_Inexlo = 0x010, /* returned result rounded toward zero */
  66. STRTOG_Inexhi = 0x020, /* returned result rounded away from zero */
  67. STRTOG_Inexact = 0x030,
  68. STRTOG_Underflow= 0x040,
  69. STRTOG_Overflow = 0x080,
  70. STRTOG_Neg = 0x100 /* does not affect STRTOG_Inexlo or STRTOG_Inexhi */
  71. };
  72. typedef struct
  73. FPI {
  74. int nbits;
  75. int emin;
  76. int emax;
  77. int rounding;
  78. int sudden_underflow;
  79. } FPI;
  80. enum { /* FPI.rounding values: same as FLT_ROUNDS */
  81. FPI_Round_zero = 0,
  82. FPI_Round_near = 1,
  83. FPI_Round_up = 2,
  84. FPI_Round_down = 3
  85. };
  86. #ifdef __cplusplus
  87. extern "C" {
  88. #endif
  89. extern char* __dtoa ANSI((double d, int mode, int ndigits, int *decpt,
  90. int *sign, char **rve));
  91. extern char* __gdtoa ANSI((FPI *fpi, int be, ULong *bits, int *kindp,
  92. int mode, int ndigits, int *decpt, char **rve));
  93. extern void __freedtoa ANSI((char*));
  94. extern int __strtodg ANSI((CONST char*, char**, FPI*, Long*, ULong*));
  95. extern int __strtorx ANSI((CONST char*, char**, int, void*));
  96. #ifdef __cplusplus
  97. }
  98. #endif
  99. #endif /* GDTOA_H_INCLUDED */