1*38fd1498Szrj /* Decimal 32-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 32-bit format module header */ 28*38fd1498Szrj /* ------------------------------------------------------------------ */ 29*38fd1498Szrj 30*38fd1498Szrj #if !defined(DECIMAL32) 31*38fd1498Szrj #define DECIMAL32 32*38fd1498Szrj #define DEC32NAME "decimal32" /* Short name */ 33*38fd1498Szrj #define DEC32FULLNAME "Decimal 32-bit Number" /* Verbose name */ 34*38fd1498Szrj #define DEC32AUTHOR "Mike Cowlishaw" /* Who to blame */ 35*38fd1498Szrj 36*38fd1498Szrj /* parameters for decimal32s */ 37*38fd1498Szrj #define DECIMAL32_Bytes 4 /* length */ 38*38fd1498Szrj #define DECIMAL32_Pmax 7 /* maximum precision (digits) */ 39*38fd1498Szrj #define DECIMAL32_Emax 96 /* maximum adjusted exponent */ 40*38fd1498Szrj #define DECIMAL32_Emin -95 /* minimum adjusted exponent */ 41*38fd1498Szrj #define DECIMAL32_Bias 101 /* bias for the exponent */ 42*38fd1498Szrj #define DECIMAL32_String 15 /* maximum string length, +1 */ 43*38fd1498Szrj #define DECIMAL32_EconL 6 /* exp. continuation length */ 44*38fd1498Szrj /* highest biased exponent (Elimit-1) */ 45*38fd1498Szrj #define DECIMAL32_Ehigh (DECIMAL32_Emax+DECIMAL32_Bias-DECIMAL32_Pmax+1) 46*38fd1498Szrj 47*38fd1498Szrj /* check enough digits, if pre-defined */ 48*38fd1498Szrj #if defined(DECNUMDIGITS) 49*38fd1498Szrj #if (DECNUMDIGITS<DECIMAL32_Pmax) 50*38fd1498Szrj #error decimal32.h needs pre-defined DECNUMDIGITS>=7 for safe use 51*38fd1498Szrj #endif 52*38fd1498Szrj #endif 53*38fd1498Szrj 54*38fd1498Szrj #ifndef DECNUMDIGITS 55*38fd1498Szrj #define DECNUMDIGITS DECIMAL32_Pmax /* size if not already defined*/ 56*38fd1498Szrj #endif 57*38fd1498Szrj #ifndef DECNUMBER 58*38fd1498Szrj #include "decNumber.h" /* context and number library */ 59*38fd1498Szrj #endif 60*38fd1498Szrj 61*38fd1498Szrj /* Decimal 32-bit type, accessible by bytes */ 62*38fd1498Szrj typedef struct { 63*38fd1498Szrj uint8_t bytes[DECIMAL32_Bytes]; /* decimal32: 1, 5, 6, 20 bits*/ 64*38fd1498Szrj } decimal32; 65*38fd1498Szrj 66*38fd1498Szrj /* special values [top byte excluding sign bit; last two bits are */ 67*38fd1498Szrj /* don't-care for Infinity on input, last bit don't-care for NaN] */ 68*38fd1498Szrj #if !defined(DECIMAL_NaN) 69*38fd1498Szrj #define DECIMAL_NaN 0x7c /* 0 11111 00 NaN */ 70*38fd1498Szrj #define DECIMAL_sNaN 0x7e /* 0 11111 10 sNaN */ 71*38fd1498Szrj #define DECIMAL_Inf 0x78 /* 0 11110 00 Infinity */ 72*38fd1498Szrj #endif 73*38fd1498Szrj 74*38fd1498Szrj /* ---------------------------------------------------------------- */ 75*38fd1498Szrj /* Routines */ 76*38fd1498Szrj /* ---------------------------------------------------------------- */ 77*38fd1498Szrj 78*38fd1498Szrj #include "decimal32Symbols.h" 79*38fd1498Szrj 80*38fd1498Szrj #ifdef __cplusplus 81*38fd1498Szrj extern "C" { 82*38fd1498Szrj #endif 83*38fd1498Szrj 84*38fd1498Szrj /* String conversions */ 85*38fd1498Szrj decimal32 * decimal32FromString(decimal32 *, const char *, decContext *); 86*38fd1498Szrj char * decimal32ToString(const decimal32 *, char *); 87*38fd1498Szrj char * decimal32ToEngString(const decimal32 *, char *); 88*38fd1498Szrj 89*38fd1498Szrj /* decNumber conversions */ 90*38fd1498Szrj decimal32 * decimal32FromNumber(decimal32 *, const decNumber *, 91*38fd1498Szrj decContext *); 92*38fd1498Szrj decNumber * decimal32ToNumber(const decimal32 *, decNumber *); 93*38fd1498Szrj 94*38fd1498Szrj /* Format-dependent utilities */ 95*38fd1498Szrj uint32_t decimal32IsCanonical(const decimal32 *); 96*38fd1498Szrj decimal32 * decimal32Canonical(decimal32 *, const decimal32 *); 97*38fd1498Szrj 98*38fd1498Szrj #ifdef __cplusplus 99*38fd1498Szrj } 100*38fd1498Szrj #endif 101*38fd1498Szrj 102*38fd1498Szrj #endif 103