Mercurial > hg > CbC > CbC_gcc
annotate libdecnumber/dpd/decimal128.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 128-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 /* ------------------------------------------------------------------ */ | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
27 /* Decimal 128-bit format module header */ |
0 | 28 /* ------------------------------------------------------------------ */ |
29 | |
30 #if !defined(DECIMAL128) | |
31 #define DECIMAL128 | |
32 #define DEC128NAME "decimal128" /* Short name */ | |
33 #define DEC128FULLNAME "Decimal 128-bit Number" /* Verbose name */ | |
34 #define DEC128AUTHOR "Mike Cowlishaw" /* Who to blame */ | |
35 | |
36 /* parameters for decimal128s */ | |
37 #define DECIMAL128_Bytes 16 /* length */ | |
38 #define DECIMAL128_Pmax 34 /* maximum precision (digits) */ | |
39 #define DECIMAL128_Emax 6144 /* maximum adjusted exponent */ | |
40 #define DECIMAL128_Emin -6143 /* minimum adjusted exponent */ | |
41 #define DECIMAL128_Bias 6176 /* bias for the exponent */ | |
42 #define DECIMAL128_String 43 /* maximum string length, +1 */ | |
43 #define DECIMAL128_EconL 12 /* 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 DECIMAL128_Ehigh (DECIMAL128_Emax+DECIMAL128_Bias-DECIMAL128_Pmax+1) |
46 | |
47 /* check enough digits, if pre-defined */ | |
48 #if defined(DECNUMDIGITS) | |
49 #if (DECNUMDIGITS<DECIMAL128_Pmax) | |
50 #error decimal128.h needs pre-defined DECNUMDIGITS>=34 for safe use | |
51 #endif | |
52 #endif | |
53 | |
54 #ifndef DECNUMDIGITS | |
55 #define DECNUMDIGITS DECIMAL128_Pmax /* size if not already defined*/ | |
56 #endif | |
57 #ifndef DECNUMBER | |
58 #include "decNumber.h" /* context and number library */ | |
59 #endif | |
60 | |
61 /* Decimal 128-bit type, accessible by bytes */ | |
62 typedef struct { | |
63 uint8_t bytes[DECIMAL128_Bytes]; /* decimal128: 1, 5, 12, 110 bits*/ | |
64 } decimal128; | |
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 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
74 #include "decimal128Local.h" |
0 | 75 |
76 /* ---------------------------------------------------------------- */ | |
77 /* Routines */ | |
78 /* ---------------------------------------------------------------- */ | |
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 #include "decimal128Symbols.h" |
0 | 81 |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
82 #ifdef __cplusplus |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
83 extern "C" { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
84 #endif |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
85 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
86 /* String conversions */ |
0 | 87 decimal128 * decimal128FromString(decimal128 *, const char *, decContext *); |
88 char * decimal128ToString(const decimal128 *, char *); | |
89 char * decimal128ToEngString(const decimal128 *, char *); | |
90 | |
91 /* decNumber conversions */ | |
92 decimal128 * decimal128FromNumber(decimal128 *, const decNumber *, | |
93 decContext *); | |
94 decNumber * decimal128ToNumber(const decimal128 *, decNumber *); | |
95 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
96 /* Format-dependent utilities */ |
0 | 97 uint32_t decimal128IsCanonical(const decimal128 *); |
98 decimal128 * decimal128Canonical(decimal128 *, const decimal128 *); | |
99 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
100 #ifdef __cplusplus |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
101 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
102 #endif |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
103 |
0 | 104 #endif |