172ac97cdSTom Musta /* Decimal 128-bit format module header for the decNumber C Library. 272ac97cdSTom Musta Copyright (C) 2005, 2007 Free Software Foundation, Inc. 372ac97cdSTom Musta Contributed by IBM Corporation. Author Mike Cowlishaw. 472ac97cdSTom Musta 572ac97cdSTom Musta This file is part of GCC. 672ac97cdSTom Musta 772ac97cdSTom Musta GCC is free software; you can redistribute it and/or modify it under 872ac97cdSTom Musta the terms of the GNU General Public License as published by the Free 972ac97cdSTom Musta Software Foundation; either version 2, or (at your option) any later 1072ac97cdSTom Musta version. 1172ac97cdSTom Musta 1272ac97cdSTom Musta In addition to the permissions in the GNU General Public License, 1372ac97cdSTom Musta the Free Software Foundation gives you unlimited permission to link 1472ac97cdSTom Musta the compiled version of this file into combinations with other 1572ac97cdSTom Musta programs, and to distribute those combinations without any 1672ac97cdSTom Musta restriction coming from the use of this file. (The General Public 1772ac97cdSTom Musta License restrictions do apply in other respects; for example, they 1872ac97cdSTom Musta cover modification of the file, and distribution when not linked 1972ac97cdSTom Musta into a combine executable.) 2072ac97cdSTom Musta 2172ac97cdSTom Musta GCC is distributed in the hope that it will be useful, but WITHOUT ANY 2272ac97cdSTom Musta WARRANTY; without even the implied warranty of MERCHANTABILITY or 2372ac97cdSTom Musta FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 2472ac97cdSTom Musta for more details. 2572ac97cdSTom Musta 2672ac97cdSTom Musta You should have received a copy of the GNU General Public License 2772ac97cdSTom Musta along with GCC; see the file COPYING. If not, write to the Free 2872ac97cdSTom Musta Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 2972ac97cdSTom Musta 02110-1301, USA. */ 3072ac97cdSTom Musta 3172ac97cdSTom Musta /* ------------------------------------------------------------------ */ 3272ac97cdSTom Musta /* Decimal 128-bit format module header */ 3372ac97cdSTom Musta /* ------------------------------------------------------------------ */ 3472ac97cdSTom Musta 35*2a6a4076SMarkus Armbruster #ifndef DECIMAL128_H 36*2a6a4076SMarkus Armbruster #define DECIMAL128_H 37*2a6a4076SMarkus Armbruster 3872ac97cdSTom Musta #define DEC128NAME "decimal128" /* Short name */ 3972ac97cdSTom Musta #define DEC128FULLNAME "Decimal 128-bit Number" /* Verbose name */ 4072ac97cdSTom Musta #define DEC128AUTHOR "Mike Cowlishaw" /* Who to blame */ 4172ac97cdSTom Musta 4272ac97cdSTom Musta /* parameters for decimal128s */ 4372ac97cdSTom Musta #define DECIMAL128_Bytes 16 /* length */ 4472ac97cdSTom Musta #define DECIMAL128_Pmax 34 /* maximum precision (digits) */ 4572ac97cdSTom Musta #define DECIMAL128_Emax 6144 /* maximum adjusted exponent */ 4672ac97cdSTom Musta #define DECIMAL128_Emin -6143 /* minimum adjusted exponent */ 4772ac97cdSTom Musta #define DECIMAL128_Bias 6176 /* bias for the exponent */ 4872ac97cdSTom Musta #define DECIMAL128_String 43 /* maximum string length, +1 */ 4972ac97cdSTom Musta #define DECIMAL128_EconL 12 /* exp. continuation length */ 5072ac97cdSTom Musta /* highest biased exponent (Elimit-1) */ 5172ac97cdSTom Musta #define DECIMAL128_Ehigh (DECIMAL128_Emax+DECIMAL128_Bias-DECIMAL128_Pmax+1) 5272ac97cdSTom Musta 5372ac97cdSTom Musta /* check enough digits, if pre-defined */ 5472ac97cdSTom Musta #if defined(DECNUMDIGITS) 5572ac97cdSTom Musta #if (DECNUMDIGITS<DECIMAL128_Pmax) 5672ac97cdSTom Musta #error decimal128.h needs pre-defined DECNUMDIGITS>=34 for safe use 5772ac97cdSTom Musta #endif 5872ac97cdSTom Musta #endif 5972ac97cdSTom Musta 6072ac97cdSTom Musta #ifndef DECNUMDIGITS 6172ac97cdSTom Musta #define DECNUMDIGITS DECIMAL128_Pmax /* size if not already defined*/ 6272ac97cdSTom Musta #endif 630f2d3732STom Musta #include "libdecnumber/decNumber.h" 6472ac97cdSTom Musta 6572ac97cdSTom Musta /* Decimal 128-bit type, accessible by bytes */ 6672ac97cdSTom Musta typedef struct { 6772ac97cdSTom Musta uint8_t bytes[DECIMAL128_Bytes]; /* decimal128: 1, 5, 12, 110 bits*/ 6872ac97cdSTom Musta } decimal128; 6972ac97cdSTom Musta 7072ac97cdSTom Musta /* special values [top byte excluding sign bit; last two bits are */ 7172ac97cdSTom Musta /* don't-care for Infinity on input, last bit don't-care for NaN] */ 7272ac97cdSTom Musta #if !defined(DECIMAL_NaN) 7372ac97cdSTom Musta #define DECIMAL_NaN 0x7c /* 0 11111 00 NaN */ 7472ac97cdSTom Musta #define DECIMAL_sNaN 0x7e /* 0 11111 10 sNaN */ 7572ac97cdSTom Musta #define DECIMAL_Inf 0x78 /* 0 11110 00 Infinity */ 7672ac97cdSTom Musta #endif 7772ac97cdSTom Musta 7872ac97cdSTom Musta #include "decimal128Local.h" 7972ac97cdSTom Musta 8072ac97cdSTom Musta /* ---------------------------------------------------------------- */ 8172ac97cdSTom Musta /* Routines */ 8272ac97cdSTom Musta /* ---------------------------------------------------------------- */ 8372ac97cdSTom Musta 8472ac97cdSTom Musta 8572ac97cdSTom Musta /* String conversions */ 8672ac97cdSTom Musta decimal128 * decimal128FromString(decimal128 *, const char *, decContext *); 8772ac97cdSTom Musta char * decimal128ToString(const decimal128 *, char *); 8872ac97cdSTom Musta char * decimal128ToEngString(const decimal128 *, char *); 8972ac97cdSTom Musta 9072ac97cdSTom Musta /* decNumber conversions */ 9172ac97cdSTom Musta decimal128 * decimal128FromNumber(decimal128 *, const decNumber *, 9272ac97cdSTom Musta decContext *); 9372ac97cdSTom Musta decNumber * decimal128ToNumber(const decimal128 *, decNumber *); 9472ac97cdSTom Musta 9572ac97cdSTom Musta /* Format-dependent utilities */ 9672ac97cdSTom Musta uint32_t decimal128IsCanonical(const decimal128 *); 9772ac97cdSTom Musta decimal128 * decimal128Canonical(decimal128 *, const decimal128 *); 9872ac97cdSTom Musta 9972ac97cdSTom Musta #endif 100