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