Back to index

cell-binutils  2.17cvs20070401
flonum.h
Go to the documentation of this file.
00001 /* flonum.h - Floating point package
00002    Copyright 1987, 1990, 1991, 1992, 1994, 1996, 2000, 2003
00003    Free Software Foundation, Inc.
00004 
00005    This file is part of GAS, the GNU Assembler.
00006 
00007    GAS is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License as published by
00009    the Free Software Foundation; either version 2, or (at your option)
00010    any later version.
00011 
00012    GAS is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015    GNU General Public License for more details.
00016 
00017    You should have received a copy of the GNU General Public License
00018    along with GAS; see the file COPYING.  If not, write to the Free
00019    Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
00020    02110-1301, USA.  */
00021 
00022 /***********************************************************************\
00023  *                                                             *
00024  *     Arbitrary-precision floating point arithmetic.                 *
00025  *                                                             *
00026  *                                                             *
00027  *     Notation: a floating point number is expressed as              *
00028  *     MANTISSA * (2 ** EXPONENT).                             *
00029  *                                                             *
00030  *     If this offends more traditional mathematicians, then          *
00031  *     please tell me your nomenclature for flonums!                  *
00032  *                                                             *
00033  \***********************************************************************/
00034 
00035 #include "bignum.h"
00036 
00037 /***********************************************************************\
00038  *                                                             *
00039  *     Variable precision floating point numbers.                     *
00040  *                                                             *
00041  *     Exponent is the place value of the low littlenum. E.g.:        *
00042  *     If  0:  low points to the units             littlenum.         *
00043  *     If  1:  low points to the LITTLENUM_RADIX   littlenum.         *
00044  *     If -1:  low points to the 1/LITTLENUM_RADIX littlenum.         *
00045  *                                                             *
00046  \***********************************************************************/
00047 
00048 /* JF:  A sign value of 0 means we have been asked to assemble NaN
00049    A sign value of 'P' means we've been asked to assemble +Inf
00050    A sign value of 'N' means we've been asked to assemble -Inf
00051    */
00052 struct FLONUM_STRUCT {
00053   LITTLENUM_TYPE *low;             /* low order littlenum of a bignum */
00054   LITTLENUM_TYPE *high;            /* high order littlenum of a bignum */
00055   LITTLENUM_TYPE *leader;   /* -> 1st non-zero littlenum */
00056   /* If flonum is 0.0, leader==low-1 */
00057   long exponent;            /* base LITTLENUM_RADIX */
00058   char sign;                /* '+' or '-' */
00059 };
00060 
00061 typedef struct FLONUM_STRUCT FLONUM_TYPE;
00062 
00063 /***********************************************************************\
00064  *                                                             *
00065  *     Since we can (& do) meet with exponents like 10^5000, it       *
00066  *     is silly to make a table of ~ 10,000 entries, one for each     *
00067  *     power of 10. We keep a table where item [n] is a struct        *
00068  *     FLONUM_FLOATING_POINT representing 10^(2^n). We then           *
00069  *     multiply appropriate entries from this table to get any        *
00070  *     particular power of 10. For the example of 10^5000, a table    *
00071  *     of just 25 entries suffices: 10^(2^-12)...10^(2^+12).          *
00072  *                                                             *
00073  \***********************************************************************/
00074 
00075 extern const FLONUM_TYPE flonum_positive_powers_of_ten[];
00076 extern const FLONUM_TYPE flonum_negative_powers_of_ten[];
00077 extern const int table_size_of_flonum_powers_of_ten;
00078 /* Flonum_XXX_powers_of_ten[] table has legal indices from 0 to
00079    + this number inclusive.  */
00080 
00081 /***********************************************************************\
00082  *                                                             *
00083  *     Declare worker functions.                               *
00084  *                                                             *
00085  \***********************************************************************/
00086 
00087 int atof_generic (char **address_of_string_pointer,
00088                 const char *string_of_decimal_marks,
00089                 const char *string_of_decimal_exponent_marks,
00090                 FLONUM_TYPE * address_of_generic_floating_point_number);
00091 
00092 void flonum_copy (FLONUM_TYPE * in, FLONUM_TYPE * out);
00093 void flonum_multip (const FLONUM_TYPE * a, const FLONUM_TYPE * b,
00094                   FLONUM_TYPE * product);
00095 
00096 /***********************************************************************\
00097  *                                                             *
00098  *     Declare error codes.                                    *
00099  *                                                             *
00100  \***********************************************************************/
00101 
00102 #define ERROR_EXPONENT_OVERFLOW (2)