]> git.ipfire.org Git - thirdparty/gcc.git/blame - libdecnumber/dpd/decimal64.h
Update copyright years.
[thirdparty/gcc.git] / libdecnumber / dpd / decimal64.h
CommitLineData
2533577f 1/* Decimal 64-bit format module header for the decNumber C Library.
7adcbafe 2 Copyright (C) 2005-2022 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
748086b7 9 Software Foundation; either version 3, or (at your option) any later
473a74b9
BE
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
748086b7
JJ
17Under Section 7 of GPL version 3, you are granted additional
18permissions described in the GCC Runtime Library Exception, version
193.1, as published by the Free Software Foundation.
20
21You should have received a copy of the GNU General Public License and
22a copy of the GCC Runtime Library Exception along with this program;
23see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
24<http://www.gnu.org/licenses/>. */
473a74b9 25
2533577f
JJ
26/* ------------------------------------------------------------------ */
27/* Decimal 64-bit format module header */
28/* ------------------------------------------------------------------ */
473a74b9 29
2533577f
JJ
30#if !defined(DECIMAL64)
31 #define DECIMAL64
32 #define DEC64NAME "decimal64" /* Short name */
7bd36a9c 33 #define DEC64FULLNAME "Decimal 64-bit Number" /* Verbose name */
2533577f
JJ
34 #define DEC64AUTHOR "Mike Cowlishaw" /* Who to blame */
35
36
37 /* parameters for decimal64s */
38 #define DECIMAL64_Bytes 8 /* length */
39 #define DECIMAL64_Pmax 16 /* maximum precision (digits) */
40 #define DECIMAL64_Emax 384 /* maximum adjusted exponent */
41 #define DECIMAL64_Emin -383 /* minimum adjusted exponent */
42 #define DECIMAL64_Bias 398 /* bias for the exponent */
43 #define DECIMAL64_String 24 /* maximum string length, +1 */
44 #define DECIMAL64_EconL 8 /* exp. continuation length */
7bd36a9c 45 /* highest biased exponent (Elimit-1) */
2533577f
JJ
46 #define DECIMAL64_Ehigh (DECIMAL64_Emax+DECIMAL64_Bias-DECIMAL64_Pmax+1)
47
48 /* check enough digits, if pre-defined */
49 #if defined(DECNUMDIGITS)
50 #if (DECNUMDIGITS<DECIMAL64_Pmax)
51 #error decimal64.h needs pre-defined DECNUMDIGITS>=16 for safe use
52 #endif
53 #endif
54
55
56 #ifndef DECNUMDIGITS
57 #define DECNUMDIGITS DECIMAL64_Pmax /* size if not already defined*/
58 #endif
59 #ifndef DECNUMBER
60 #include "decNumber.h" /* context and number library */
61 #endif
62
63 /* Decimal 64-bit type, accessible by bytes */
64 typedef struct {
65 uint8_t bytes[DECIMAL64_Bytes]; /* decimal64: 1, 5, 8, 50 bits*/
66 } decimal64;
67
68 /* special values [top byte excluding sign bit; last two bits are */
69 /* don't-care for Infinity on input, last bit don't-care for NaN] */
70 #if !defined(DECIMAL_NaN)
7bd36a9c 71 #define DECIMAL_NaN 0x7c /* 0 11111 00 NaN */
2533577f 72 #define DECIMAL_sNaN 0x7e /* 0 11111 10 sNaN */
7bd36a9c 73 #define DECIMAL_Inf 0x78 /* 0 11110 00 Infinity */
2533577f
JJ
74 #endif
75
76 /* ---------------------------------------------------------------- */
77 /* Routines */
78 /* ---------------------------------------------------------------- */
79
7bd36a9c 80#include "decimal64Symbols.h"
2533577f 81
6863c0f0
ILT
82 #ifdef __cplusplus
83 extern "C" {
84 #endif
85
7bd36a9c 86 /* String conversions */
2533577f
JJ
87 decimal64 * decimal64FromString(decimal64 *, const char *, decContext *);
88 char * decimal64ToString(const decimal64 *, char *);
89 char * decimal64ToEngString(const decimal64 *, char *);
90
91 /* decNumber conversions */
92 decimal64 * decimal64FromNumber(decimal64 *, const decNumber *,
93 decContext *);
94 decNumber * decimal64ToNumber(const decimal64 *, decNumber *);
95
7bd36a9c 96 /* Format-dependent utilities */
2533577f
JJ
97 uint32_t decimal64IsCanonical(const decimal64 *);
98 decimal64 * decimal64Canonical(decimal64 *, const decimal64 *);
473a74b9 99
6863c0f0
ILT
100 #ifdef __cplusplus
101 }
102 #endif
103
473a74b9 104#endif