15796c8dcSSimon Schubert /* Decimal 32-bit format module header for the decNumber C Library. 2*ef5ccd6cSJohn Marino Copyright (C) 2005-2013 Free Software Foundation, Inc. 35796c8dcSSimon Schubert Contributed by IBM Corporation. Author Mike Cowlishaw. 45796c8dcSSimon Schubert 55796c8dcSSimon Schubert This file is part of GCC. 65796c8dcSSimon Schubert 75796c8dcSSimon Schubert GCC is free software; you can redistribute it and/or modify it under 85796c8dcSSimon Schubert the terms of the GNU General Public License as published by the Free 95796c8dcSSimon Schubert Software Foundation; either version 3, or (at your option) any later 105796c8dcSSimon Schubert version. 115796c8dcSSimon Schubert 125796c8dcSSimon Schubert GCC is distributed in the hope that it will be useful, but WITHOUT ANY 135796c8dcSSimon Schubert WARRANTY; without even the implied warranty of MERCHANTABILITY or 145796c8dcSSimon Schubert FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 155796c8dcSSimon Schubert for more details. 165796c8dcSSimon Schubert 175796c8dcSSimon Schubert Under Section 7 of GPL version 3, you are granted additional 185796c8dcSSimon Schubert permissions described in the GCC Runtime Library Exception, version 195796c8dcSSimon Schubert 3.1, as published by the Free Software Foundation. 205796c8dcSSimon Schubert 215796c8dcSSimon Schubert You should have received a copy of the GNU General Public License and 225796c8dcSSimon Schubert a copy of the GCC Runtime Library Exception along with this program; 235796c8dcSSimon Schubert see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 245796c8dcSSimon Schubert <http://www.gnu.org/licenses/>. */ 255796c8dcSSimon Schubert 265796c8dcSSimon Schubert /* ------------------------------------------------------------------ */ 275796c8dcSSimon Schubert /* Decimal 32-bit format module header */ 285796c8dcSSimon Schubert /* ------------------------------------------------------------------ */ 295796c8dcSSimon Schubert 305796c8dcSSimon Schubert #if !defined(DECIMAL32) 315796c8dcSSimon Schubert #define DECIMAL32 325796c8dcSSimon Schubert #define DEC32NAME "decimal32" /* Short name */ 335796c8dcSSimon Schubert #define DEC32FULLNAME "Decimal 32-bit Number" /* Verbose name */ 345796c8dcSSimon Schubert #define DEC32AUTHOR "Mike Cowlishaw" /* Who to blame */ 355796c8dcSSimon Schubert 365796c8dcSSimon Schubert /* parameters for decimal32s */ 375796c8dcSSimon Schubert #define DECIMAL32_Bytes 4 /* length */ 385796c8dcSSimon Schubert #define DECIMAL32_Pmax 7 /* maximum precision (digits) */ 395796c8dcSSimon Schubert #define DECIMAL32_Emax 96 /* maximum adjusted exponent */ 405796c8dcSSimon Schubert #define DECIMAL32_Emin -95 /* minimum adjusted exponent */ 415796c8dcSSimon Schubert #define DECIMAL32_Bias 101 /* bias for the exponent */ 425796c8dcSSimon Schubert #define DECIMAL32_String 15 /* maximum string length, +1 */ 435796c8dcSSimon Schubert #define DECIMAL32_EconL 6 /* exp. continuation length */ 445796c8dcSSimon Schubert /* highest biased exponent (Elimit-1) */ 455796c8dcSSimon Schubert #define DECIMAL32_Ehigh (DECIMAL32_Emax+DECIMAL32_Bias-DECIMAL32_Pmax+1) 465796c8dcSSimon Schubert 475796c8dcSSimon Schubert /* check enough digits, if pre-defined */ 485796c8dcSSimon Schubert #if defined(DECNUMDIGITS) 495796c8dcSSimon Schubert #if (DECNUMDIGITS<DECIMAL32_Pmax) 505796c8dcSSimon Schubert #error decimal32.h needs pre-defined DECNUMDIGITS>=7 for safe use 515796c8dcSSimon Schubert #endif 525796c8dcSSimon Schubert #endif 535796c8dcSSimon Schubert 545796c8dcSSimon Schubert #ifndef DECNUMDIGITS 555796c8dcSSimon Schubert #define DECNUMDIGITS DECIMAL32_Pmax /* size if not already defined*/ 565796c8dcSSimon Schubert #endif 575796c8dcSSimon Schubert #ifndef DECNUMBER 585796c8dcSSimon Schubert #include "decNumber.h" /* context and number library */ 595796c8dcSSimon Schubert #endif 605796c8dcSSimon Schubert 615796c8dcSSimon Schubert /* Decimal 32-bit type, accessible by bytes */ 625796c8dcSSimon Schubert typedef struct { 635796c8dcSSimon Schubert uint8_t bytes[DECIMAL32_Bytes]; /* decimal32: 1, 5, 6, 20 bits*/ 645796c8dcSSimon Schubert } decimal32; 655796c8dcSSimon Schubert 665796c8dcSSimon Schubert /* special values [top byte excluding sign bit; last two bits are */ 675796c8dcSSimon Schubert /* don't-care for Infinity on input, last bit don't-care for NaN] */ 685796c8dcSSimon Schubert #if !defined(DECIMAL_NaN) 695796c8dcSSimon Schubert #define DECIMAL_NaN 0x7c /* 0 11111 00 NaN */ 705796c8dcSSimon Schubert #define DECIMAL_sNaN 0x7e /* 0 11111 10 sNaN */ 715796c8dcSSimon Schubert #define DECIMAL_Inf 0x78 /* 0 11110 00 Infinity */ 725796c8dcSSimon Schubert #endif 735796c8dcSSimon Schubert 745796c8dcSSimon Schubert /* ---------------------------------------------------------------- */ 755796c8dcSSimon Schubert /* Routines */ 765796c8dcSSimon Schubert /* ---------------------------------------------------------------- */ 775796c8dcSSimon Schubert 785796c8dcSSimon Schubert #include "decimal32Symbols.h" 795796c8dcSSimon Schubert 805796c8dcSSimon Schubert #ifdef __cplusplus 815796c8dcSSimon Schubert extern "C" { 825796c8dcSSimon Schubert #endif 835796c8dcSSimon Schubert 845796c8dcSSimon Schubert /* String conversions */ 855796c8dcSSimon Schubert decimal32 * decimal32FromString(decimal32 *, const char *, decContext *); 865796c8dcSSimon Schubert char * decimal32ToString(const decimal32 *, char *); 875796c8dcSSimon Schubert char * decimal32ToEngString(const decimal32 *, char *); 885796c8dcSSimon Schubert 895796c8dcSSimon Schubert /* decNumber conversions */ 905796c8dcSSimon Schubert decimal32 * decimal32FromNumber(decimal32 *, const decNumber *, 915796c8dcSSimon Schubert decContext *); 925796c8dcSSimon Schubert decNumber * decimal32ToNumber(const decimal32 *, decNumber *); 935796c8dcSSimon Schubert 945796c8dcSSimon Schubert /* Format-dependent utilities */ 955796c8dcSSimon Schubert uint32_t decimal32IsCanonical(const decimal32 *); 965796c8dcSSimon Schubert decimal32 * decimal32Canonical(decimal32 *, const decimal32 *); 975796c8dcSSimon Schubert 985796c8dcSSimon Schubert #ifdef __cplusplus 995796c8dcSSimon Schubert } 1005796c8dcSSimon Schubert #endif 1015796c8dcSSimon Schubert 1025796c8dcSSimon Schubert #endif 103