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