1 /* number.h: Arbitrary precision numbers header file. */
3 /* This file is part of GNU bc.
4 Copyright (C) 1991, 1992, 1993, 1994, 1997 Free Software Foundation, Inc.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License , or
9 (at your option) any later version.
11 This program 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.
16 You should have received a copy of the GNU General Public License
17 along with this program; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20 You may contact the author by:
21 e-mail: phil@cs.wwu.edu
22 us-mail: Philip A. Nelson
23 Computer Science Department, 9062
24 Western Washington University
25 Bellingham, WA 98226-9062
27 *************************************************************************/
30 typedef enum {PLUS, MINUS} sign;
35 int n_len; /* The number of digits before the decimal point. */
36 int n_scale; /* The number of digits after the decimal point. */
37 int n_refs; /* The number of pointers to this number. */
38 char n_value[1]; /* The storage. Not zero char terminated. It is
39 allocated with all other fields. */
42 typedef bc_struct *bc_num;
44 /* The base used in storing the numbers in n_value above.
45 Currently this MUST be 10. */
49 /* Some useful macros and constants. */
51 #define CH_VAL(c) (c - '0')
52 #define BCD_CHAR(d) (d + '0')
58 #define MAX(a,b) ((a)>(b)?(a):(b))
59 #define MIN(a,b) ((a)>(b)?(b):(a))
60 #define ODD(a) ((a)&1)