]> git.ipfire.org Git - thirdparty/gcc.git/blame - libdecnumber/dpd/decimal32.h
Update copyright years.
[thirdparty/gcc.git] / libdecnumber / dpd / decimal32.h
CommitLineData
2533577f 1/* Decimal 32-bit format module header for the decNumber C Library.
8d9254fc 2 Copyright (C) 2005-2020 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 32-bit format module header */
28/* ------------------------------------------------------------------ */
29
473a74b9 30#if !defined(DECIMAL32)
2533577f
JJ
31 #define DECIMAL32
32 #define DEC32NAME "decimal32" /* Short name */
7bd36a9c 33 #define DEC32FULLNAME "Decimal 32-bit Number" /* Verbose name */
2533577f 34 #define DEC32AUTHOR "Mike Cowlishaw" /* Who to blame */
473a74b9
BE
35
36 /* parameters for decimal32s */
2533577f
JJ
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 */
7bd36a9c 44 /* highest biased exponent (Elimit-1) */
2533577f
JJ
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
473a74b9
BE
60
61 /* Decimal 32-bit type, accessible by bytes */
2533577f
JJ
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)
7bd36a9c 69 #define DECIMAL_NaN 0x7c /* 0 11111 00 NaN */
2533577f 70 #define DECIMAL_sNaN 0x7e /* 0 11111 10 sNaN */
7bd36a9c 71 #define DECIMAL_Inf 0x78 /* 0 11110 00 Infinity */
2533577f
JJ
72 #endif
73
74 /* ---------------------------------------------------------------- */
75 /* Routines */
76 /* ---------------------------------------------------------------- */
77
7bd36a9c 78#include "decimal32Symbols.h"
2533577f 79
6863c0f0
ILT
80 #ifdef __cplusplus
81 extern "C" {
82 #endif
83
7bd36a9c 84 /* String conversions */
2533577f
JJ
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
7bd36a9c 94 /* Format-dependent utilities */
2533577f
JJ
95 uint32_t decimal32IsCanonical(const decimal32 *);
96 decimal32 * decimal32Canonical(decimal32 *, const decimal32 *);
473a74b9 97
6863c0f0
ILT
98 #ifdef __cplusplus
99 }
100 #endif
101
473a74b9 102#endif