1 /* flonum.h - Floating point package
3 Copyright (C) 1987, 1990, 1991, 1992 Free Software Foundation, Inc.
5 This file is part of GAS, the GNU Assembler.
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)
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.
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
19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
21 * $FreeBSD: src/gnu/usr.bin/as/flonum.h,v 1.6 1999/08/27 23:34:15 peter Exp $
22 * $DragonFly: src/gnu/usr.bin/as/Attic/flonum.h,v 1.2 2003/06/17 04:25:44 dillon Exp $
26 /***********************************************************************\
28 * Arbitrary-precision floating point arithmetic. *
31 * Notation: a floating point number is expressed as *
32 * MANTISSA * (2 ** EXPONENT). *
34 * If this offends more traditional mathematicians, then *
35 * please tell me your nomenclature for flonums! *
37 \***********************************************************************/
38 #if (__STDC__ != 1) && !defined(const)
39 #define const /* empty */
44 /***********************************************************************\
46 * Variable precision floating point numbers. *
48 * Exponent is the place value of the low littlenum. E.g.: *
49 * If 0: low points to the units littlenum. *
50 * If 1: low points to the LITTLENUM_RADIX littlenum. *
51 * If -1: low points to the 1/LITTLENUM_RADIX littlenum. *
53 \***********************************************************************/
55 /* JF: A sign value of 0 means we have been asked to assemble NaN
56 A sign value of 'P' means we've been asked to assemble +Inf
57 A sign value of 'N' means we've been asked to assemble -Inf
61 LITTLENUM_TYPE *low; /* low order littlenum of a bignum */
62 LITTLENUM_TYPE *high; /* high order littlenum of a bignum */
63 LITTLENUM_TYPE *leader; /* -> 1st non-zero littlenum */
64 /* If flonum is 0.0, leader == low-1 */
65 long exponent; /* base LITTLENUM_RADIX */
66 char sign; /* '+' or '-' */
69 typedef struct FLONUM_STRUCT FLONUM_TYPE;
72 /***********************************************************************\
74 * Since we can (& do) meet with exponents like 10^5000, it *
75 * is silly to make a table of ~ 10,000 entries, one for each *
76 * power of 10. We keep a table where item [n] is a struct *
77 * FLONUM_FLOATING_POINT representing 10^(2^n). We then *
78 * multiply appropriate entries from this table to get any *
79 * particular power of 10. For the example of 10^5000, a table *
80 * of just 25 entries suffices: 10^(2^-12)...10^(2^+12). *
82 \***********************************************************************/
85 extern const FLONUM_TYPE flonum_positive_powers_of_ten[];
86 extern const FLONUM_TYPE flonum_negative_powers_of_ten[];
87 extern const int table_size_of_flonum_powers_of_ten;
88 /* Flonum_XXX_powers_of_ten[] table has */
89 /* legal indices from 0 to */
90 /* + this number inclusive. */
94 /***********************************************************************\
96 * Declare worker functions. *
98 \***********************************************************************/
102 int atof_generic(char **address_of_string_pointer,
103 const char *string_of_decimal_marks,
104 const char *string_of_decimal_exponent_marks,
105 FLONUM_TYPE *address_of_generic_floating_point_number);
107 void flonum_copy(FLONUM_TYPE *in, FLONUM_TYPE *out);
108 void flonum_multip(const FLONUM_TYPE *a, const FLONUM_TYPE *b, FLONUM_TYPE *product);
110 #else /* not __STDC__ */
114 void flonum_multip();
116 #endif /* not __STDC__ */
118 /***********************************************************************\
120 * Declare error codes. *
122 \***********************************************************************/
124 #define ERROR_EXPONENT_OVERFLOW (2)
126 /* end of flonum.h */