home *** CD-ROM | disk | FTP | other *** search
/ Dream 52 / Amiga_Dream_52.iso / Atari / Gnu / gassrc04.zoo / flonum.h < prev    next >
C/C++ Source or Header  |  1991-01-24  |  4KB  |  112 lines

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