OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [libdecnumber/] [decNumber.h] - Blame information for rev 816

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 38 julius
/* Decimal Number module header for the decNumber C Library
2
   Copyright (C) 2005 Free Software Foundation, Inc.
3
   Contributed by IBM Corporation.  Author Mike Cowlishaw.
4
 
5
   This file is part of GCC.
6
 
7
   GCC is free software; you can redistribute it and/or modify it under
8
   the terms of the GNU General Public License as published by the Free
9
   Software Foundation; either version 2, or (at your option) any later
10
   version.
11
 
12
   In addition to the permissions in the GNU General Public License,
13
   the Free Software Foundation gives you unlimited permission to link
14
   the compiled version of this file into combinations with other
15
   programs, and to distribute those combinations without any
16
   restriction coming from the use of this file.  (The General Public
17
   License restrictions do apply in other respects; for example, they
18
   cover modification of the file, and distribution when not linked
19
   into a combine executable.)
20
 
21
   GCC is distributed in the hope that it will be useful, but WITHOUT ANY
22
   WARRANTY; without even the implied warranty of MERCHANTABILITY or
23
   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
24
   for more details.
25
 
26
   You should have received a copy of the GNU General Public License
27
   along with GCC; see the file COPYING.  If not, write to the Free
28
   Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
29
   02110-1301, USA.  */
30
 
31
#if !defined(DECNUMBER)
32
#define DECNUMBER
33
#define DECNAME     "decNumber" /* Short name */
34
#define DECVERSION  "decNumber 3.24"    /* Version [16 max.] */
35
#define DECFULLNAME "Decimal Number Module"     /* Verbose name */
36
#define DECAUTHOR   "Mike Cowlishaw"    /* Who to blame */
37
 
38
#if !defined(DECCONTEXT)
39
#include "decContext.h"
40
#endif
41
 
42
 
43
  /* Bit settings for decNumber.bits */
44
#define DECNEG    0x80          /* Sign; 1=negative, 0=positive or zero */
45
#define DECINF    0x40          /* 1=Infinity */
46
#define DECNAN    0x20          /* 1=NaN */
47
#define DECSNAN   0x10          /* 1=sNaN */
48
  /* The remaining bits are reserved; they must be 0 */
49
#define DECSPECIAL (DECINF|DECNAN|DECSNAN)      /* any special value */
50
 
51
  /* DECNUMDIGITS is the default number of digits we can hold in the */
52
  /* structure.  If undefined, 1 is assumed and it is assumed that the */
53
  /* structure will be immediately followed by extra space (if */
54
  /* required).  DECNUMDIGITS is always >0. */
55
#if !defined(DECNUMDIGITS)
56
#define DECNUMDIGITS 1
57
#endif
58
 
59
 
60
  /* Define the decNumber data structure.  The size and shape of the */
61
  /* units array in the structure is determined by the following */
62
  /* constant.  This must not be changed without recompiling the */
63
  /* decNumber library modules. */
64
#define DECDPUN 4               /* Decimal Digits Per UNit [must be in */
65
                                   /* range 1-9; power of 2 recommended]. */
66
  /* The size (integer data type) of each unit is determined by the */
67
  /* number of digits it will hold. */
68
#if   DECDPUN<=2
69
#define decNumberUnit uint8_t
70
#elif DECDPUN<=4
71
#define decNumberUnit uint16_t
72
#else
73
#define decNumberUnit uint32_t
74
#endif
75
  /* The number of decNumberUnits we need is ceiling of DECNUMDIGITS/DECDPUN */
76
#define DECNUMUNITS ((DECNUMDIGITS+DECDPUN-1)/DECDPUN)
77
 
78
  /* The data structure... */
79
typedef struct
80
{
81
  int32_t digits;               /* Count of digits in the coefficient; >0 */
82
  int32_t exponent;             /* Unadjusted exponent, unbiased, in */
83
  /* range: -1999999997 through 999999999 */
84
  uint8_t bits;                 /* Indicator bits (see above) */
85
  decNumberUnit lsu[DECNUMUNITS];       /* Coefficient, from least significant unit */
86
} decNumber;
87
 
88
  /* Notes: */
89
  /* 1. If digits is > DECDPUN then there will be more than one */
90
  /*    decNumberUnits immediately following the first element of lsu. */
91
  /*    These contain the remaining (more significant) digits of the */
92
  /*    number, and may be in the lsu array, or may be guaranteed by */
93
  /*    some other mechanism (such as being contained in another */
94
  /*    structure, or being overlaid on dynamically allocated storage). */
95
  /* */
96
  /*    Each integer of the coefficient (except the possibly the last) */
97
  /*    contains DECDPUN digits (e.g., a value in the range 0 through */
98
  /*    99999999 if DECDPUN is 8, or 0 through 9999 if DECDPUN is 4). */
99
  /* */
100
  /* 2. A decNumber converted to a string may need up to digits+14 */
101
  /*    characters.  The worst cases (non-exponential and exponential */
102
  /*    formats) are: -0.00000{9...}# */
103
  /*             and: -9.{9...}E+999999999#   (where # is '\0') */
104
 
105
 
106
  /* ------------------------------------------------------------------ */
107
  /* decNumber public functions and macros                              */
108
  /* ------------------------------------------------------------------ */
109
 
110
#ifdef IN_LIBGCC2
111
#define decNumberFromString __decNumberFromString
112
#define decNumberToString __decNumberToString
113
#define decNumberToEngString __decNumberToEngString
114
#define decNumberAbs __decNumberAbs
115
#define decNumberAdd __decNumberAdd
116
#define decNumberCompare __decNumberCompare
117
#define decNumberDivide __decNumberDivide
118
#define decNumberDivideInteger __decNumberDivideInteger
119
#define decNumberMax __decNumberMax
120
#define decNumberMin __decNumberMin
121
#define decNumberMinus __decNumberMinus
122
#define decNumberMultiply __decNumberMultiply
123
#define decNumberNormalize __decNumberNormalize
124
#define decNumberPlus __decNumberPlus
125
#define decNumberPower __decNumberPower
126
#define decNumberQuantize __decNumberQuantize
127
#define decNumberRemainder __decNumberRemainder
128
#define decNumberRemainderNear __decNumberRemainderNear
129
#define decNumberRescale __decNumberRescale
130
#define decNumberSameQuantum __decNumberSameQuantum
131
#define decNumberSquareRoot __decNumberSquareRoot
132
#define decNumberSubtract __decNumberSubtract
133
#define decNumberToIntegralValue __decNumberToIntegralValue
134
#define decNumberCopy __decNumberCopy
135
#define decNumberTrim __decNumberTrim
136
#define decNumberVersion __decNumberVersion
137
#define decNumberZero __decNumberZero
138
#endif
139
 
140
  /* Conversions */
141 152 jeremybenn
 
142
/* The following two functions are copied from later versions, since  */
143
/* they are needed by GDB which shares this library.                  */
144
 
145
decNumber *decNumberFromInt32(decNumber *, int32_t);
146
decNumber *decNumberFromUInt32(decNumber *, uint32_t);
147
 
148 38 julius
decNumber *decNumberFromString (decNumber *, const char *, decContext *);
149
char *decNumberToString (const decNumber *, char *);
150
char *decNumberToEngString (const decNumber *, char *);
151
 
152
  /* Operators */
153
decNumber *decNumberAbs (decNumber *, const decNumber *, decContext *);
154
decNumber *decNumberAdd (decNumber *, const decNumber *,
155
                         const decNumber *, decContext *);
156
decNumber *decNumberCompare (decNumber *, const decNumber *,
157
                             const decNumber *, decContext *);
158
decNumber *decNumberDivide (decNumber *, const decNumber *,
159
                            const decNumber *, decContext *);
160
decNumber *decNumberDivideInteger (decNumber *, const decNumber *,
161
                                   const decNumber *, decContext *);
162
decNumber *decNumberMax (decNumber *, const decNumber *,
163
                         const decNumber *, decContext *);
164
decNumber *decNumberMin (decNumber *, const decNumber *,
165
                         const decNumber *, decContext *);
166
decNumber *decNumberMinus (decNumber *, const decNumber *, decContext *);
167
decNumber *decNumberMultiply (decNumber *, const decNumber *,
168
                              const decNumber *, decContext *);
169
decNumber *decNumberNormalize (decNumber *, const decNumber *, decContext *);
170
decNumber *decNumberPlus (decNumber *, const decNumber *, decContext *);
171
decNumber *decNumberPower (decNumber *, const decNumber *,
172
                           const decNumber *, decContext *);
173
decNumber *decNumberQuantize (decNumber *, const decNumber *,
174
                              const decNumber *, decContext *);
175
decNumber *decNumberRemainder (decNumber *, const decNumber *,
176
                               const decNumber *, decContext *);
177
decNumber *decNumberRemainderNear (decNumber *, const decNumber *,
178
                                   const decNumber *, decContext *);
179
decNumber *decNumberRescale (decNumber *, const decNumber *,
180
                             const decNumber *, decContext *);
181
decNumber *decNumberSameQuantum (decNumber *, const decNumber *, const decNumber *);
182
decNumber *decNumberSquareRoot (decNumber *, const decNumber *, decContext *);
183
decNumber *decNumberSubtract (decNumber *, const decNumber *,
184
                              const decNumber *, decContext *);
185
decNumber *decNumberToIntegralValue (decNumber *, const decNumber *, decContext *);
186
 
187
  /* Utilities */
188
decNumber *decNumberCopy (decNumber *, const decNumber *);
189
decNumber *decNumberTrim (decNumber *);
190
const char *decNumberVersion (void);
191
decNumber *decNumberZero (decNumber *);
192
 
193
  /* Macros */
194
#define decNumberIsZero(dn)     (*(dn)->lsu==0 \
195
                                   && (dn)->digits==1 \
196
                                   && (((dn)->bits&DECSPECIAL)==0))
197
#define decNumberIsNegative(dn) (((dn)->bits&DECNEG)!=0)
198
#define decNumberIsNaN(dn)      (((dn)->bits&(DECNAN|DECSNAN))!=0)
199
#define decNumberIsInfinite(dn) (((dn)->bits&DECINF)!=0)
200
 
201
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.