1*38fd1498Szrj /* Decimal 64-bit format module header for the decNumber C Library. 2*38fd1498Szrj Copyright (C) 2005-2018 Free Software Foundation, Inc. 3*38fd1498Szrj Contributed by IBM Corporation. Author Mike Cowlishaw. 4*38fd1498Szrj 5*38fd1498Szrj This file is part of GCC. 6*38fd1498Szrj 7*38fd1498Szrj GCC is free software; you can redistribute it and/or modify it under 8*38fd1498Szrj the terms of the GNU General Public License as published by the Free 9*38fd1498Szrj Software Foundation; either version 3, or (at your option) any later 10*38fd1498Szrj version. 11*38fd1498Szrj 12*38fd1498Szrj GCC is distributed in the hope that it will be useful, but WITHOUT ANY 13*38fd1498Szrj WARRANTY; without even the implied warranty of MERCHANTABILITY or 14*38fd1498Szrj FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15*38fd1498Szrj for more details. 16*38fd1498Szrj 17*38fd1498Szrj Under Section 7 of GPL version 3, you are granted additional 18*38fd1498Szrj permissions described in the GCC Runtime Library Exception, version 19*38fd1498Szrj 3.1, as published by the Free Software Foundation. 20*38fd1498Szrj 21*38fd1498Szrj You should have received a copy of the GNU General Public License and 22*38fd1498Szrj a copy of the GCC Runtime Library Exception along with this program; 23*38fd1498Szrj see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 24*38fd1498Szrj <http://www.gnu.org/licenses/>. */ 25*38fd1498Szrj 26*38fd1498Szrj /* ------------------------------------------------------------------ */ 27*38fd1498Szrj /* Decimal 64-bit format module header */ 28*38fd1498Szrj /* ------------------------------------------------------------------ */ 29*38fd1498Szrj 30*38fd1498Szrj #if !defined(DECIMAL64) 31*38fd1498Szrj #define DECIMAL64 32*38fd1498Szrj #define DEC64NAME "decimal64" /* Short name */ 33*38fd1498Szrj #define DEC64FULLNAME "Decimal 64-bit Number" /* Verbose name */ 34*38fd1498Szrj #define DEC64AUTHOR "Mike Cowlishaw" /* Who to blame */ 35*38fd1498Szrj 36*38fd1498Szrj 37*38fd1498Szrj /* parameters for decimal64s */ 38*38fd1498Szrj #define DECIMAL64_Bytes 8 /* length */ 39*38fd1498Szrj #define DECIMAL64_Pmax 16 /* maximum precision (digits) */ 40*38fd1498Szrj #define DECIMAL64_Emax 384 /* maximum adjusted exponent */ 41*38fd1498Szrj #define DECIMAL64_Emin -383 /* minimum adjusted exponent */ 42*38fd1498Szrj #define DECIMAL64_Bias 398 /* bias for the exponent */ 43*38fd1498Szrj #define DECIMAL64_String 24 /* maximum string length, +1 */ 44*38fd1498Szrj #define DECIMAL64_EconL 8 /* exp. continuation length */ 45*38fd1498Szrj /* highest biased exponent (Elimit-1) */ 46*38fd1498Szrj #define DECIMAL64_Ehigh (DECIMAL64_Emax+DECIMAL64_Bias-DECIMAL64_Pmax+1) 47*38fd1498Szrj 48*38fd1498Szrj /* check enough digits, if pre-defined */ 49*38fd1498Szrj #if defined(DECNUMDIGITS) 50*38fd1498Szrj #if (DECNUMDIGITS<DECIMAL64_Pmax) 51*38fd1498Szrj #error decimal64.h needs pre-defined DECNUMDIGITS>=16 for safe use 52*38fd1498Szrj #endif 53*38fd1498Szrj #endif 54*38fd1498Szrj 55*38fd1498Szrj 56*38fd1498Szrj #ifndef DECNUMDIGITS 57*38fd1498Szrj #define DECNUMDIGITS DECIMAL64_Pmax /* size if not already defined*/ 58*38fd1498Szrj #endif 59*38fd1498Szrj #ifndef DECNUMBER 60*38fd1498Szrj #include "decNumber.h" /* context and number library */ 61*38fd1498Szrj #endif 62*38fd1498Szrj 63*38fd1498Szrj /* Decimal 64-bit type, accessible by bytes */ 64*38fd1498Szrj typedef struct { 65*38fd1498Szrj uint8_t bytes[DECIMAL64_Bytes]; /* decimal64: 1, 5, 8, 50 bits*/ 66*38fd1498Szrj } decimal64; 67*38fd1498Szrj 68*38fd1498Szrj /* special values [top byte excluding sign bit; last two bits are */ 69*38fd1498Szrj /* don't-care for Infinity on input, last bit don't-care for NaN] */ 70*38fd1498Szrj #if !defined(DECIMAL_NaN) 71*38fd1498Szrj #define DECIMAL_NaN 0x7c /* 0 11111 00 NaN */ 72*38fd1498Szrj #define DECIMAL_sNaN 0x7e /* 0 11111 10 sNaN */ 73*38fd1498Szrj #define DECIMAL_Inf 0x78 /* 0 11110 00 Infinity */ 74*38fd1498Szrj #endif 75*38fd1498Szrj 76*38fd1498Szrj /* ---------------------------------------------------------------- */ 77*38fd1498Szrj /* Routines */ 78*38fd1498Szrj /* ---------------------------------------------------------------- */ 79*38fd1498Szrj 80*38fd1498Szrj #include "decimal64Symbols.h" 81*38fd1498Szrj 82*38fd1498Szrj #ifdef __cplusplus 83*38fd1498Szrj extern "C" { 84*38fd1498Szrj #endif 85*38fd1498Szrj 86*38fd1498Szrj /* String conversions */ 87*38fd1498Szrj decimal64 * decimal64FromString(decimal64 *, const char *, decContext *); 88*38fd1498Szrj char * decimal64ToString(const decimal64 *, char *); 89*38fd1498Szrj char * decimal64ToEngString(const decimal64 *, char *); 90*38fd1498Szrj 91*38fd1498Szrj /* decNumber conversions */ 92*38fd1498Szrj decimal64 * decimal64FromNumber(decimal64 *, const decNumber *, 93*38fd1498Szrj decContext *); 94*38fd1498Szrj decNumber * decimal64ToNumber(const decimal64 *, decNumber *); 95*38fd1498Szrj 96*38fd1498Szrj /* Format-dependent utilities */ 97*38fd1498Szrj uint32_t decimal64IsCanonical(const decimal64 *); 98*38fd1498Szrj decimal64 * decimal64Canonical(decimal64 *, const decimal64 *); 99*38fd1498Szrj 100*38fd1498Szrj #ifdef __cplusplus 101*38fd1498Szrj } 102*38fd1498Szrj #endif 103*38fd1498Szrj 104*38fd1498Szrj #endif 105