Mercurial > hg > CbC > CbC_gcc
annotate libdecnumber/dpd/decimal32.h @ 158:494b0b89df80 default tip
...
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 25 May 2020 18:13:55 +0900 |
parents | 1830386684a0 |
children |
rev | line source |
---|---|
0 | 1 /* Decimal 32-bit format module header for the decNumber C Library. |
145 | 2 Copyright (C) 2005-2020 Free Software Foundation, Inc. |
0 | 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 3, or (at your option) any later | |
10 version. | |
11 | |
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY | |
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 Under Section 7 of GPL version 3, you are granted additional | |
18 permissions described in the GCC Runtime Library Exception, version | |
19 3.1, as published by the Free Software Foundation. | |
20 | |
21 You should have received a copy of the GNU General Public License and | |
22 a copy of the GCC Runtime Library Exception along with this program; | |
23 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see | |
24 <http://www.gnu.org/licenses/>. */ | |
25 | |
26 /* ------------------------------------------------------------------ */ | |
27 /* Decimal 32-bit format module header */ | |
28 /* ------------------------------------------------------------------ */ | |
29 | |
30 #if !defined(DECIMAL32) | |
31 #define DECIMAL32 | |
32 #define DEC32NAME "decimal32" /* Short name */ | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
33 #define DEC32FULLNAME "Decimal 32-bit Number" /* Verbose name */ |
0 | 34 #define DEC32AUTHOR "Mike Cowlishaw" /* Who to blame */ |
35 | |
36 /* parameters for decimal32s */ | |
37 #define DECIMAL32_Bytes 4 /* length */ | |
38 #define DECIMAL32_Pmax 7 /* maximum precision (digits) */ | |
39 #define DECIMAL32_Emax 96 /* maximum adjusted exponent */ | |
40 #define DECIMAL32_Emin -95 /* minimum adjusted exponent */ | |
41 #define DECIMAL32_Bias 101 /* bias for the exponent */ | |
42 #define DECIMAL32_String 15 /* maximum string length, +1 */ | |
43 #define DECIMAL32_EconL 6 /* exp. continuation length */ | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
44 /* highest biased exponent (Elimit-1) */ |
0 | 45 #define DECIMAL32_Ehigh (DECIMAL32_Emax+DECIMAL32_Bias-DECIMAL32_Pmax+1) |
46 | |
47 /* check enough digits, if pre-defined */ | |
48 #if defined(DECNUMDIGITS) | |
49 #if (DECNUMDIGITS<DECIMAL32_Pmax) | |
50 #error decimal32.h needs pre-defined DECNUMDIGITS>=7 for safe use | |
51 #endif | |
52 #endif | |
53 | |
54 #ifndef DECNUMDIGITS | |
55 #define DECNUMDIGITS DECIMAL32_Pmax /* size if not already defined*/ | |
56 #endif | |
57 #ifndef DECNUMBER | |
58 #include "decNumber.h" /* context and number library */ | |
59 #endif | |
60 | |
61 /* Decimal 32-bit type, accessible by bytes */ | |
62 typedef struct { | |
63 uint8_t bytes[DECIMAL32_Bytes]; /* decimal32: 1, 5, 6, 20 bits*/ | |
64 } decimal32; | |
65 | |
66 /* special values [top byte excluding sign bit; last two bits are */ | |
67 /* don't-care for Infinity on input, last bit don't-care for NaN] */ | |
68 #if !defined(DECIMAL_NaN) | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
69 #define DECIMAL_NaN 0x7c /* 0 11111 00 NaN */ |
0 | 70 #define DECIMAL_sNaN 0x7e /* 0 11111 10 sNaN */ |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
71 #define DECIMAL_Inf 0x78 /* 0 11110 00 Infinity */ |
0 | 72 #endif |
73 | |
74 /* ---------------------------------------------------------------- */ | |
75 /* Routines */ | |
76 /* ---------------------------------------------------------------- */ | |
77 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
78 #include "decimal32Symbols.h" |
0 | 79 |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
80 #ifdef __cplusplus |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
81 extern "C" { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
82 #endif |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
83 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
84 /* String conversions */ |
0 | 85 decimal32 * decimal32FromString(decimal32 *, const char *, decContext *); |
86 char * decimal32ToString(const decimal32 *, char *); | |
87 char * decimal32ToEngString(const decimal32 *, char *); | |
88 | |
89 /* decNumber conversions */ | |
90 decimal32 * decimal32FromNumber(decimal32 *, const decNumber *, | |
91 decContext *); | |
92 decNumber * decimal32ToNumber(const decimal32 *, decNumber *); | |
93 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
94 /* Format-dependent utilities */ |
0 | 95 uint32_t decimal32IsCanonical(const decimal32 *); |
96 decimal32 * decimal32Canonical(decimal32 *, const decimal32 *); | |
97 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
98 #ifdef __cplusplus |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
99 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
100 #endif |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
101 |
0 | 102 #endif |