]> git.ipfire.org Git - thirdparty/gcc.git/blame - libdecnumber/dpd/decimal128.h
re PR testsuite/39696 (gcc.dg/tree-ssa/ssa-ccp-25.c scan-tree-dump doesn't work on...
[thirdparty/gcc.git] / libdecnumber / dpd / decimal128.h
CommitLineData
2533577f
JJ
1/* Decimal 128-bit format module header for the decNumber C Library.
2 Copyright (C) 2005, 2007 Free Software Foundation, Inc.
473a74b9
BE
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
9d1d1cd4
BE
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
473a74b9
BE
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
c0173136
BE
28 Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
29 02110-1301, USA. */
473a74b9 30
2533577f 31/* ------------------------------------------------------------------ */
7bd36a9c 32/* Decimal 128-bit format module header */
2533577f
JJ
33/* ------------------------------------------------------------------ */
34
473a74b9 35#if !defined(DECIMAL128)
2533577f
JJ
36 #define DECIMAL128
37 #define DEC128NAME "decimal128" /* Short name */
38 #define DEC128FULLNAME "Decimal 128-bit Number" /* Verbose name */
39 #define DEC128AUTHOR "Mike Cowlishaw" /* Who to blame */
473a74b9
BE
40
41 /* parameters for decimal128s */
2533577f
JJ
42 #define DECIMAL128_Bytes 16 /* length */
43 #define DECIMAL128_Pmax 34 /* maximum precision (digits) */
44 #define DECIMAL128_Emax 6144 /* maximum adjusted exponent */
45 #define DECIMAL128_Emin -6143 /* minimum adjusted exponent */
46 #define DECIMAL128_Bias 6176 /* bias for the exponent */
47 #define DECIMAL128_String 43 /* maximum string length, +1 */
48 #define DECIMAL128_EconL 12 /* exp. continuation length */
7bd36a9c 49 /* highest biased exponent (Elimit-1) */
2533577f
JJ
50 #define DECIMAL128_Ehigh (DECIMAL128_Emax+DECIMAL128_Bias-DECIMAL128_Pmax+1)
51
52 /* check enough digits, if pre-defined */
53 #if defined(DECNUMDIGITS)
54 #if (DECNUMDIGITS<DECIMAL128_Pmax)
55 #error decimal128.h needs pre-defined DECNUMDIGITS>=34 for safe use
56 #endif
57 #endif
58
59 #ifndef DECNUMDIGITS
60 #define DECNUMDIGITS DECIMAL128_Pmax /* size if not already defined*/
61 #endif
62 #ifndef DECNUMBER
63 #include "decNumber.h" /* context and number library */
64 #endif
65
66 /* Decimal 128-bit type, accessible by bytes */
67 typedef struct {
68 uint8_t bytes[DECIMAL128_Bytes]; /* decimal128: 1, 5, 12, 110 bits*/
69 } decimal128;
70
71 /* special values [top byte excluding sign bit; last two bits are */
72 /* don't-care for Infinity on input, last bit don't-care for NaN] */
73 #if !defined(DECIMAL_NaN)
7bd36a9c 74 #define DECIMAL_NaN 0x7c /* 0 11111 00 NaN */
2533577f 75 #define DECIMAL_sNaN 0x7e /* 0 11111 10 sNaN */
7bd36a9c 76 #define DECIMAL_Inf 0x78 /* 0 11110 00 Infinity */
2533577f
JJ
77 #endif
78
7bd36a9c 79#include "decimal128Local.h"
2533577f
JJ
80
81 /* ---------------------------------------------------------------- */
82 /* Routines */
83 /* ---------------------------------------------------------------- */
84
7bd36a9c 85#include "decimal128Symbols.h"
2533577f 86
7bd36a9c 87 /* String conversions */
2533577f
JJ
88 decimal128 * decimal128FromString(decimal128 *, const char *, decContext *);
89 char * decimal128ToString(const decimal128 *, char *);
90 char * decimal128ToEngString(const decimal128 *, char *);
91
92 /* decNumber conversions */
93 decimal128 * decimal128FromNumber(decimal128 *, const decNumber *,
94 decContext *);
95 decNumber * decimal128ToNumber(const decimal128 *, decNumber *);
96
7bd36a9c 97 /* Format-dependent utilities */
2533577f
JJ
98 uint32_t decimal128IsCanonical(const decimal128 *);
99 decimal128 * decimal128Canonical(decimal128 *, const decimal128 *);
473a74b9
BE
100
101#endif