flonum.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /* flonum.h - Floating point package
  2. Copyright (C) 1987 Free Software Foundation, Inc.
  3. This file is part of GAS, the GNU Assembler.
  4. GAS is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 1, or (at your option)
  7. any later version.
  8. GAS is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GAS; see the file COPYING. If not, write to
  14. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
  15. /***********************************************************************\
  16. * *
  17. * Arbitrary-precision floating point arithmetic. *
  18. * *
  19. * *
  20. * Notation: a floating point number is expressed as *
  21. * MANTISSA * (2 ** EXPONENT). *
  22. * *
  23. * If this offends more traditional mathematicians, then *
  24. * please tell me your nomenclature for flonums! *
  25. * *
  26. \***********************************************************************/
  27. #include "bignum.h"
  28. /***********************************************************************\
  29. * *
  30. * Variable precision floating point numbers. *
  31. * *
  32. * Exponent is the place value of the low littlenum. E.g.: *
  33. * If 0: low points to the units littlenum. *
  34. * If 1: low points to the LITTLENUM_RADIX littlenum. *
  35. * If -1: low points to the 1/LITTLENUM_RADIX littlenum. *
  36. * *
  37. \***********************************************************************/
  38. /* JF: A sign value of 0 means we have been asked to assemble NaN
  39. A sign value of 'P' means we've been asked to assemble +Inf
  40. A sign value of 'N' means we've been asked to assemble -Inf
  41. */
  42. struct FLONUM_STRUCT
  43. {
  44. LITTLENUM_TYPE * low; /* low order littlenum of a bignum */
  45. LITTLENUM_TYPE * high; /* high order littlenum of a bignum */
  46. LITTLENUM_TYPE * leader; /* -> 1st non-zero littlenum */
  47. /* If flonum is 0.0, leader==low-1 */
  48. long int exponent; /* base LITTLENUM_RADIX */
  49. char sign; /* '+' or '-' */
  50. };
  51. typedef struct FLONUM_STRUCT FLONUM_TYPE;
  52. /***********************************************************************\
  53. * *
  54. * Since we can (& do) meet with exponents like 10^5000, it *
  55. * is silly to make a table of ~ 10,000 entries, one for each *
  56. * power of 10. We keep a table where item [n] is a struct *
  57. * FLONUM_FLOATING_POINT representing 10^(2^n). We then *
  58. * multiply appropriate entries from this table to get any *
  59. * particular power of 10. For the example of 10^5000, a table *
  60. * of just 25 entries suffices: 10^(2^-12)...10^(2^+12). *
  61. * *
  62. \***********************************************************************/
  63. extern FLONUM_TYPE flonum_positive_powers_of_ten[];
  64. extern FLONUM_TYPE flonum_negative_powers_of_ten[];
  65. extern int table_size_of_flonum_powers_of_ten;
  66. /* Flonum_XXX_powers_of_ten[] table has */
  67. /* legal indices from 0 to */
  68. /* + this number inclusive. */
  69. /***********************************************************************\
  70. * *
  71. * Declare worker functions. *
  72. * *
  73. \***********************************************************************/
  74. void flonum_multip();
  75. void flonum_copy();
  76. void flonum_print();
  77. char * flonum_get(); /* Returns "" or error string. */
  78. void flonum_normal();
  79. int atof_generic();
  80. /***********************************************************************\
  81. * *
  82. * Declare error codes. *
  83. * *
  84. \***********************************************************************/
  85. #define ERROR_EXPONENT_OVERFLOW (2)
  86. /* end: flonum.h */