133965Sjdp/* flonum.h - Floating point package 2218822Sdim Copyright 1987, 1990, 1991, 1992, 1994, 1996, 2000, 2003 377298Sobrien Free Software Foundation, Inc. 433965Sjdp 533965Sjdp This file is part of GAS, the GNU Assembler. 633965Sjdp 733965Sjdp GAS is free software; you can redistribute it and/or modify 833965Sjdp it under the terms of the GNU General Public License as published by 933965Sjdp the Free Software Foundation; either version 2, or (at your option) 1033965Sjdp any later version. 1133965Sjdp 1233965Sjdp GAS is distributed in the hope that it will be useful, 1333965Sjdp but WITHOUT ANY WARRANTY; without even the implied warranty of 1433965Sjdp MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1533965Sjdp GNU General Public License for more details. 1633965Sjdp 1733965Sjdp You should have received a copy of the GNU General Public License 1833965Sjdp along with GAS; see the file COPYING. If not, write to the Free 19218822Sdim Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 20218822Sdim 02110-1301, USA. */ 2133965Sjdp 2233965Sjdp/***********************************************************************\ 2333965Sjdp * * 2433965Sjdp * Arbitrary-precision floating point arithmetic. * 2533965Sjdp * * 2633965Sjdp * * 2733965Sjdp * Notation: a floating point number is expressed as * 2833965Sjdp * MANTISSA * (2 ** EXPONENT). * 2933965Sjdp * * 3033965Sjdp * If this offends more traditional mathematicians, then * 3133965Sjdp * please tell me your nomenclature for flonums! * 3233965Sjdp * * 3333965Sjdp \***********************************************************************/ 3433965Sjdp 3533965Sjdp#include "bignum.h" 3633965Sjdp 3733965Sjdp/***********************************************************************\ 3833965Sjdp * * 3933965Sjdp * Variable precision floating point numbers. * 4033965Sjdp * * 4133965Sjdp * Exponent is the place value of the low littlenum. E.g.: * 4233965Sjdp * If 0: low points to the units littlenum. * 4333965Sjdp * If 1: low points to the LITTLENUM_RADIX littlenum. * 4433965Sjdp * If -1: low points to the 1/LITTLENUM_RADIX littlenum. * 4533965Sjdp * * 4633965Sjdp \***********************************************************************/ 4733965Sjdp 4833965Sjdp/* JF: A sign value of 0 means we have been asked to assemble NaN 4933965Sjdp A sign value of 'P' means we've been asked to assemble +Inf 5033965Sjdp A sign value of 'N' means we've been asked to assemble -Inf 5133965Sjdp */ 5277298Sobrienstruct FLONUM_STRUCT { 5333965Sjdp LITTLENUM_TYPE *low; /* low order littlenum of a bignum */ 5433965Sjdp LITTLENUM_TYPE *high; /* high order littlenum of a bignum */ 5533965Sjdp LITTLENUM_TYPE *leader; /* -> 1st non-zero littlenum */ 5633965Sjdp /* If flonum is 0.0, leader==low-1 */ 5733965Sjdp long exponent; /* base LITTLENUM_RADIX */ 5833965Sjdp char sign; /* '+' or '-' */ 5933965Sjdp}; 6033965Sjdp 6133965Sjdptypedef struct FLONUM_STRUCT FLONUM_TYPE; 6233965Sjdp 6333965Sjdp/***********************************************************************\ 6433965Sjdp * * 6533965Sjdp * Since we can (& do) meet with exponents like 10^5000, it * 6633965Sjdp * is silly to make a table of ~ 10,000 entries, one for each * 6733965Sjdp * power of 10. We keep a table where item [n] is a struct * 6833965Sjdp * FLONUM_FLOATING_POINT representing 10^(2^n). We then * 6933965Sjdp * multiply appropriate entries from this table to get any * 7033965Sjdp * particular power of 10. For the example of 10^5000, a table * 7133965Sjdp * of just 25 entries suffices: 10^(2^-12)...10^(2^+12). * 7233965Sjdp * * 7333965Sjdp \***********************************************************************/ 7433965Sjdp 7533965Sjdpextern const FLONUM_TYPE flonum_positive_powers_of_ten[]; 7633965Sjdpextern const FLONUM_TYPE flonum_negative_powers_of_ten[]; 7733965Sjdpextern const int table_size_of_flonum_powers_of_ten; 7877298Sobrien/* Flonum_XXX_powers_of_ten[] table has legal indices from 0 to 7977298Sobrien + this number inclusive. */ 8033965Sjdp 8133965Sjdp/***********************************************************************\ 8233965Sjdp * * 8333965Sjdp * Declare worker functions. * 8433965Sjdp * * 8533965Sjdp \***********************************************************************/ 8633965Sjdp 87130561Sobrienint atof_generic (char **address_of_string_pointer, 88130561Sobrien const char *string_of_decimal_marks, 89130561Sobrien const char *string_of_decimal_exponent_marks, 90130561Sobrien FLONUM_TYPE * address_of_generic_floating_point_number); 9133965Sjdp 92130561Sobrienvoid flonum_copy (FLONUM_TYPE * in, FLONUM_TYPE * out); 93130561Sobrienvoid flonum_multip (const FLONUM_TYPE * a, const FLONUM_TYPE * b, 94130561Sobrien FLONUM_TYPE * product); 9533965Sjdp 9633965Sjdp/***********************************************************************\ 9733965Sjdp * * 9833965Sjdp * Declare error codes. * 9933965Sjdp * * 10033965Sjdp \***********************************************************************/ 10133965Sjdp 10233965Sjdp#define ERROR_EXPONENT_OVERFLOW (2) 103