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