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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-6.8/] [libdecnumber/] [decNumber.h] - Blame information for rev 325

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 24 jeremybenn
/* Decimal number arithmetic module header for the decNumber C Library.
2
   Copyright (C) 2005, 2007 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
/* ------------------------------------------------------------------ */
32
/* Decimal Number arithmetic module header                            */
33
/* ------------------------------------------------------------------ */
34
 
35
#if !defined(DECNUMBER)
36
  #define DECNUMBER
37
  #define DECNAME     "decNumber"                       /* Short name */
38
  #define DECFULLNAME "Decimal Number Module"         /* Verbose name */
39
  #define DECAUTHOR   "Mike Cowlishaw"                /* Who to blame */
40
 
41
  #if !defined(DECCONTEXT)
42
    #include "decContext.h"
43
  #endif
44
 
45
  /* Bit settings for decNumber.bits                                  */
46
  #define DECNEG    0x80      /* Sign; 1=negative, 0=positive or zero */
47
  #define DECINF    0x40      /* 1=Infinity                           */
48
  #define DECNAN    0x20      /* 1=NaN                                */
49
  #define DECSNAN   0x10      /* 1=sNaN                               */
50
  /* The remaining bits are reserved; they must be 0                  */
51
  #define DECSPECIAL (DECINF|DECNAN|DECSNAN) /* any special value     */
52
 
53
  /* Define the decNumber data structure.  The size and shape of the  */
54
  /* units array in the structure is determined by the following      */
55
  /* constant.  This must not be changed without recompiling the      */
56
  /* decNumber library modules. */
57
 
58
  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
59
                              /* and <10; 3 or powers of 2 are best]. */
60
 
61
  /* DECNUMDIGITS is the default number of digits that can be held in */
62
  /* the structure.  If undefined, 1 is assumed and it is assumed     */
63
  /* that the structure will be immediately followed by extra space,  */
64
  /* as required.  DECNUMDIGITS is always >0.                         */
65
  #if !defined(DECNUMDIGITS)
66
    #define DECNUMDIGITS 1
67
  #endif
68
 
69
  /* The size (integer data type) of each unit is determined by the   */
70
  /* number of digits it will hold.                                   */
71
  #if   DECDPUN<=2
72
    #define decNumberUnit uint8_t
73
  #elif DECDPUN<=4
74
    #define decNumberUnit uint16_t
75
  #else
76
    #define decNumberUnit uint32_t
77
  #endif
78
  /* The number of units needed is ceil(DECNUMDIGITS/DECDPUN)         */
79
  #define DECNUMUNITS ((DECNUMDIGITS+DECDPUN-1)/DECDPUN)
80
 
81
  /* The data structure... */
82
  typedef struct {
83
    int32_t digits;      /* Count of digits in the coefficient; >0    */
84
    int32_t exponent;    /* Unadjusted exponent, unbiased, in         */
85
                         /* range: -1999999997 through 999999999      */
86
    uint8_t bits;        /* Indicator bits (see above)                */
87
                         /* Coefficient, from least significant unit  */
88
    decNumberUnit lsu[DECNUMUNITS];
89
    } decNumber;
90
 
91
  /* Notes:                                                           */
92
  /* 1. If digits is > DECDPUN then there will one or more            */
93
  /*    decNumberUnits immediately following the first element of lsu.*/
94
  /*    These contain the remaining (more significant) digits of the  */
95
  /*    number, and may be in the lsu array, or may be guaranteed by  */
96
  /*    some other mechanism (such as being contained in another      */
97
  /*    structure, or being overlaid on dynamically allocated         */
98
  /*    storage).                                                     */
99
  /*                                                                  */
100
  /*    Each integer of the coefficient (except potentially the last) */
101
  /*    contains DECDPUN digits (e.g., a value in the range 0 through */
102
  /*    99999999 if DECDPUN is 8, or 0 through 999 if DECDPUN is 3).  */
103
  /*                                                                  */
104
  /* 2. A decNumber converted to a string may need up to digits+14    */
105
  /*    characters.  The worst cases (non-exponential and exponential */
106
  /*    formats) are -0.00000{9...}# and -9.{9...}E+999999999#        */
107
  /*    (where # is '\0')                                             */
108
 
109
 
110
  /* ---------------------------------------------------------------- */
111
  /* decNumber public functions and macros                            */
112
  /* ---------------------------------------------------------------- */
113
 
114
  #include "decNumberSymbols.h"
115
 
116
  /* Conversions                                                      */
117
  decNumber * decNumberFromInt32(decNumber *, int32_t);
118
  decNumber * decNumberFromUInt32(decNumber *, uint32_t);
119
  decNumber * decNumberFromString(decNumber *, const char *, decContext *);
120
  char      * decNumberToString(const decNumber *, char *);
121
  char      * decNumberToEngString(const decNumber *, char *);
122
  uint32_t    decNumberToUInt32(const decNumber *, decContext *);
123
  int32_t     decNumberToInt32(const decNumber *, decContext *);
124
  uint8_t   * decNumberGetBCD(const decNumber *, uint8_t *);
125
  decNumber * decNumberSetBCD(decNumber *, const uint8_t *, uint32_t);
126
 
127
  /* Operators and elementary functions                               */
128
  decNumber * decNumberAbs(decNumber *, const decNumber *, decContext *);
129
  decNumber * decNumberAdd(decNumber *, const decNumber *, const decNumber *, decContext *);
130
  decNumber * decNumberAnd(decNumber *, const decNumber *, const decNumber *, decContext *);
131
  decNumber * decNumberCompare(decNumber *, const decNumber *, const decNumber *, decContext *);
132
  decNumber * decNumberCompareSignal(decNumber *, const decNumber *, const decNumber *, decContext *);
133
  decNumber * decNumberCompareTotal(decNumber *, const decNumber *, const decNumber *, decContext *);
134
  decNumber * decNumberCompareTotalMag(decNumber *, const decNumber *, const decNumber *, decContext *);
135
  decNumber * decNumberDivide(decNumber *, const decNumber *, const decNumber *, decContext *);
136
  decNumber * decNumberDivideInteger(decNumber *, const decNumber *, const decNumber *, decContext *);
137
  decNumber * decNumberExp(decNumber *, const decNumber *, decContext *);
138
  decNumber * decNumberFMA(decNumber *, const decNumber *, const decNumber *, const decNumber *, decContext *);
139
  decNumber * decNumberInvert(decNumber *, const decNumber *, decContext *);
140
  decNumber * decNumberLn(decNumber *, const decNumber *, decContext *);
141
  decNumber * decNumberLogB(decNumber *, const decNumber *, decContext *);
142
  decNumber * decNumberLog10(decNumber *, const decNumber *, decContext *);
143
  decNumber * decNumberMax(decNumber *, const decNumber *, const decNumber *, decContext *);
144
  decNumber * decNumberMaxMag(decNumber *, const decNumber *, const decNumber *, decContext *);
145
  decNumber * decNumberMin(decNumber *, const decNumber *, const decNumber *, decContext *);
146
  decNumber * decNumberMinMag(decNumber *, const decNumber *, const decNumber *, decContext *);
147
  decNumber * decNumberMinus(decNumber *, const decNumber *, decContext *);
148
  decNumber * decNumberMultiply(decNumber *, const decNumber *, const decNumber *, decContext *);
149
  decNumber * decNumberNormalize(decNumber *, const decNumber *, decContext *);
150
  decNumber * decNumberOr(decNumber *, const decNumber *, const decNumber *, decContext *);
151
  decNumber * decNumberPlus(decNumber *, const decNumber *, decContext *);
152
  decNumber * decNumberPower(decNumber *, const decNumber *, const decNumber *, decContext *);
153
  decNumber * decNumberQuantize(decNumber *, const decNumber *, const decNumber *, decContext *);
154
  decNumber * decNumberReduce(decNumber *, const decNumber *, decContext *);
155
  decNumber * decNumberRemainder(decNumber *, const decNumber *, const decNumber *, decContext *);
156
  decNumber * decNumberRemainderNear(decNumber *, const decNumber *, const decNumber *, decContext *);
157
  decNumber * decNumberRescale(decNumber *, const decNumber *, const decNumber *, decContext *);
158
  decNumber * decNumberRotate(decNumber *, const decNumber *, const decNumber *, decContext *);
159
  decNumber * decNumberSameQuantum(decNumber *, const decNumber *, const decNumber *);
160
  decNumber * decNumberScaleB(decNumber *, const decNumber *, const decNumber *, decContext *);
161
  decNumber * decNumberShift(decNumber *, const decNumber *, const decNumber *, decContext *);
162
  decNumber * decNumberSquareRoot(decNumber *, const decNumber *, decContext *);
163
  decNumber * decNumberSubtract(decNumber *, const decNumber *, const decNumber *, decContext *);
164
  decNumber * decNumberToIntegralExact(decNumber *, const decNumber *, decContext *);
165
  decNumber * decNumberToIntegralValue(decNumber *, const decNumber *, decContext *);
166
  decNumber * decNumberXor(decNumber *, const decNumber *, const decNumber *, decContext *);
167
 
168
  /* Utilities                                                        */
169
  enum decClass decNumberClass(const decNumber *, decContext *);
170
  const char * decNumberClassToString(enum decClass);
171
  decNumber  * decNumberCopy(decNumber *, const decNumber *);
172
  decNumber  * decNumberCopyAbs(decNumber *, const decNumber *);
173
  decNumber  * decNumberCopyNegate(decNumber *, const decNumber *);
174
  decNumber  * decNumberCopySign(decNumber *, const decNumber *, const decNumber *);
175
  decNumber  * decNumberNextMinus(decNumber *, const decNumber *, decContext *);
176
  decNumber  * decNumberNextPlus(decNumber *, const decNumber *, decContext *);
177
  decNumber  * decNumberNextToward(decNumber *, const decNumber *, const decNumber *, decContext *);
178
  decNumber  * decNumberTrim(decNumber *);
179
  const char * decNumberVersion(void);
180
  decNumber  * decNumberZero(decNumber *);
181
 
182
  /* Functions for testing decNumbers (normality depends on context)  */
183
  int32_t decNumberIsNormal(const decNumber *, decContext *);
184
  int32_t decNumberIsSubnormal(const decNumber *, decContext *);
185
 
186
  /* Macros for testing decNumber *dn                                 */
187
  #define decNumberIsCanonical(dn) (1)  /* All decNumbers are saintly */
188
  #define decNumberIsFinite(dn)    (((dn)->bits&DECSPECIAL)==0)
189
  #define decNumberIsInfinite(dn)  (((dn)->bits&DECINF)!=0)
190
  #define decNumberIsNaN(dn)       (((dn)->bits&(DECNAN|DECSNAN))!=0)
191
  #define decNumberIsNegative(dn)  (((dn)->bits&DECNEG)!=0)
192
  #define decNumberIsQNaN(dn)      (((dn)->bits&(DECNAN))!=0)
193
  #define decNumberIsSNaN(dn)      (((dn)->bits&(DECSNAN))!=0)
194
  #define decNumberIsSpecial(dn)   (((dn)->bits&DECSPECIAL)!=0)
195
  #define decNumberIsZero(dn)      (*(dn)->lsu==0 \
196
                                    && (dn)->digits==1 \
197
                                    && (((dn)->bits&DECSPECIAL)==0))
198
  #define decNumberRadix(dn)       (10)
199
 
200
#endif

powered by: WebSVN 2.1.0

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