15796c8dcSSimon Schubert /* Decimal 64-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 64-bit format module header */ 285796c8dcSSimon Schubert /* ------------------------------------------------------------------ */ 295796c8dcSSimon Schubert 305796c8dcSSimon Schubert #if !defined(DECIMAL64) 315796c8dcSSimon Schubert #define DECIMAL64 325796c8dcSSimon Schubert #define DEC64NAME "decimal64" /* Short name */ 335796c8dcSSimon Schubert #define DEC64FULLNAME "Decimal 64-bit Number" /* Verbose name */ 345796c8dcSSimon Schubert #define DEC64AUTHOR "Mike Cowlishaw" /* Who to blame */ 355796c8dcSSimon Schubert 365796c8dcSSimon Schubert 375796c8dcSSimon Schubert /* parameters for decimal64s */ 385796c8dcSSimon Schubert #define DECIMAL64_Bytes 8 /* length */ 395796c8dcSSimon Schubert #define DECIMAL64_Pmax 16 /* maximum precision (digits) */ 405796c8dcSSimon Schubert #define DECIMAL64_Emax 384 /* maximum adjusted exponent */ 415796c8dcSSimon Schubert #define DECIMAL64_Emin -383 /* minimum adjusted exponent */ 425796c8dcSSimon Schubert #define DECIMAL64_Bias 398 /* bias for the exponent */ 435796c8dcSSimon Schubert #define DECIMAL64_String 24 /* maximum string length, +1 */ 445796c8dcSSimon Schubert #define DECIMAL64_EconL 8 /* exp. continuation length */ 455796c8dcSSimon Schubert /* highest biased exponent (Elimit-1) */ 465796c8dcSSimon Schubert #define DECIMAL64_Ehigh (DECIMAL64_Emax+DECIMAL64_Bias-DECIMAL64_Pmax+1) 475796c8dcSSimon Schubert 485796c8dcSSimon Schubert /* check enough digits, if pre-defined */ 495796c8dcSSimon Schubert #if defined(DECNUMDIGITS) 505796c8dcSSimon Schubert #if (DECNUMDIGITS<DECIMAL64_Pmax) 515796c8dcSSimon Schubert #error decimal64.h needs pre-defined DECNUMDIGITS>=16 for safe use 525796c8dcSSimon Schubert #endif 535796c8dcSSimon Schubert #endif 545796c8dcSSimon Schubert 555796c8dcSSimon Schubert 565796c8dcSSimon Schubert #ifndef DECNUMDIGITS 575796c8dcSSimon Schubert #define DECNUMDIGITS DECIMAL64_Pmax /* size if not already defined*/ 585796c8dcSSimon Schubert #endif 595796c8dcSSimon Schubert #ifndef DECNUMBER 605796c8dcSSimon Schubert #include "decNumber.h" /* context and number library */ 615796c8dcSSimon Schubert #endif 625796c8dcSSimon Schubert 635796c8dcSSimon Schubert /* Decimal 64-bit type, accessible by bytes */ 645796c8dcSSimon Schubert typedef struct { 655796c8dcSSimon Schubert uint8_t bytes[DECIMAL64_Bytes]; /* decimal64: 1, 5, 8, 50 bits*/ 665796c8dcSSimon Schubert } decimal64; 675796c8dcSSimon Schubert 685796c8dcSSimon Schubert /* special values [top byte excluding sign bit; last two bits are */ 695796c8dcSSimon Schubert /* don't-care for Infinity on input, last bit don't-care for NaN] */ 705796c8dcSSimon Schubert #if !defined(DECIMAL_NaN) 715796c8dcSSimon Schubert #define DECIMAL_NaN 0x7c /* 0 11111 00 NaN */ 725796c8dcSSimon Schubert #define DECIMAL_sNaN 0x7e /* 0 11111 10 sNaN */ 735796c8dcSSimon Schubert #define DECIMAL_Inf 0x78 /* 0 11110 00 Infinity */ 745796c8dcSSimon Schubert #endif 755796c8dcSSimon Schubert 765796c8dcSSimon Schubert /* ---------------------------------------------------------------- */ 775796c8dcSSimon Schubert /* Routines */ 785796c8dcSSimon Schubert /* ---------------------------------------------------------------- */ 795796c8dcSSimon Schubert 805796c8dcSSimon Schubert #include "decimal64Symbols.h" 815796c8dcSSimon Schubert 825796c8dcSSimon Schubert #ifdef __cplusplus 835796c8dcSSimon Schubert extern "C" { 845796c8dcSSimon Schubert #endif 855796c8dcSSimon Schubert 865796c8dcSSimon Schubert /* String conversions */ 875796c8dcSSimon Schubert decimal64 * decimal64FromString(decimal64 *, const char *, decContext *); 885796c8dcSSimon Schubert char * decimal64ToString(const decimal64 *, char *); 895796c8dcSSimon Schubert char * decimal64ToEngString(const decimal64 *, char *); 905796c8dcSSimon Schubert 915796c8dcSSimon Schubert /* decNumber conversions */ 925796c8dcSSimon Schubert decimal64 * decimal64FromNumber(decimal64 *, const decNumber *, 935796c8dcSSimon Schubert decContext *); 945796c8dcSSimon Schubert decNumber * decimal64ToNumber(const decimal64 *, decNumber *); 955796c8dcSSimon Schubert 965796c8dcSSimon Schubert /* Format-dependent utilities */ 975796c8dcSSimon Schubert uint32_t decimal64IsCanonical(const decimal64 *); 985796c8dcSSimon Schubert decimal64 * decimal64Canonical(decimal64 *, const decimal64 *); 995796c8dcSSimon Schubert 1005796c8dcSSimon Schubert #ifdef __cplusplus 1015796c8dcSSimon Schubert } 1025796c8dcSSimon Schubert #endif 1035796c8dcSSimon Schubert 1045796c8dcSSimon Schubert #endif 105