]> Git Repo - binutils.git/blob - gas/flonum.h
Fix comment.
[binutils.git] / gas / flonum.h
1 /* flonum.h - Floating point package
2    Copyright (C) 1987, 1990, 1991 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 /* $Id$ */
21
22 /***********************************************************************\
23 *                                                                       *
24 *       Arbitrary-precision floating point arithmetic.                  *
25 *                                                                       *
26 *                                                                       *
27 *       Notation: a floating point number is expressed as               *
28 *       MANTISSA * (2 ** EXPONENT).                                     *
29 *                                                                       *
30 *       If this offends more traditional mathematicians, then           *
31 *       please tell me your nomenclature for flonums!                   *
32 *                                                                       *
33 \***********************************************************************/
34 #if !defined(__STDC__) && !defined(const)
35 #define const /* empty */
36 #endif
37
38 #include "bignum.h"
39
40 /***********************************************************************\
41 *                                                                       *
42 *       Variable precision floating point numbers.                      *
43 *                                                                       *
44 *       Exponent is the place value of the low littlenum. E.g.:         *
45 *       If  0:  low points to the units             littlenum.          *
46 *       If  1:  low points to the LITTLENUM_RADIX   littlenum.          *
47 *       If -1:  low points to the 1/LITTLENUM_RADIX littlenum.          *
48 *                                                                       *
49 \***********************************************************************/
50
51 /* JF:  A sign value of 0 means we have been asked to assemble NaN
52    A sign value of 'P' means we've been asked to assemble +Inf
53    A sign value of 'N' means we've been asked to assemble -Inf
54  */
55 struct FLONUM_STRUCT
56 {
57   LITTLENUM_TYPE *      low;    /* low order littlenum of a bignum */
58   LITTLENUM_TYPE *      high;   /* high order littlenum of a bignum */
59   LITTLENUM_TYPE *      leader; /* -> 1st non-zero littlenum */
60                                 /* If flonum is 0.0, leader==low-1 */
61   long          exponent; /* base LITTLENUM_RADIX */
62   char                  sign;   /* '+' or '-' */
63 };
64
65 typedef struct FLONUM_STRUCT FLONUM_TYPE;
66
67
68 /***********************************************************************\
69 *                                                                       *
70 *       Since we can (& do) meet with exponents like 10^5000, it        *
71 *       is silly to make a table of ~ 10,000 entries, one for each      *
72 *       power of 10. We keep a table where item [n] is a struct         *
73 *       FLONUM_FLOATING_POINT representing 10^(2^n). We then            *
74 *       multiply appropriate entries from this table to get any         *
75 *       particular power of 10. For the example of 10^5000, a table     *
76 *       of just 25 entries suffices: 10^(2^-12)...10^(2^+12).           *
77 *                                                                       *
78 \***********************************************************************/
79
80
81 extern const FLONUM_TYPE flonum_positive_powers_of_ten[];
82 extern const FLONUM_TYPE flonum_negative_powers_of_ten[];
83 extern const int table_size_of_flonum_powers_of_ten;
84                                 /* Flonum_XXX_powers_of_ten[] table has */
85                                 /* legal indices from 0 to */
86                                 /* + this number inclusive. */
87
88
89
90 /***********************************************************************\
91 *                                                                       *
92 *       Declare worker functions.                                       *
93 *                                                                       *
94 \***********************************************************************/
95
96 #ifdef __STDC__
97
98 int atof_generic(char **address_of_string_pointer,
99                  const char *string_of_decimal_marks,
100                  const char *string_of_decimal_exponent_marks,
101                  FLONUM_TYPE *address_of_generic_floating_point_number);
102
103 void flonum_copy(FLONUM_TYPE *in, FLONUM_TYPE *out);
104 void flonum_multip(const FLONUM_TYPE *a, const FLONUM_TYPE *b, FLONUM_TYPE *product);
105
106 #else /* __STDC__ */
107
108 int atof_generic();
109 void flonum_copy();
110 void flonum_multip();
111
112 #endif /* __STDC__ */
113
114 /***********************************************************************\
115 *                                                                       *
116 *       Declare error codes.                                            *
117 *                                                                       *
118 \***********************************************************************/
119
120 #define ERROR_EXPONENT_OVERFLOW (2)
121
122 /* end: flonum.h */
This page took 0.030809 seconds and 4 git commands to generate.