172ac97cdSTom Musta /* Decimal 32-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 32-bit format module header */ 3372ac97cdSTom Musta /* ------------------------------------------------------------------ */ 3472ac97cdSTom Musta 35*2a6a4076SMarkus Armbruster #ifndef DECIMAL32_H 36*2a6a4076SMarkus Armbruster #define DECIMAL32_H 37*2a6a4076SMarkus Armbruster 3872ac97cdSTom Musta #define DEC32NAME "decimal32" /* Short name */ 3972ac97cdSTom Musta #define DEC32FULLNAME "Decimal 32-bit Number" /* Verbose name */ 4072ac97cdSTom Musta #define DEC32AUTHOR "Mike Cowlishaw" /* Who to blame */ 4172ac97cdSTom Musta 4272ac97cdSTom Musta /* parameters for decimal32s */ 4372ac97cdSTom Musta #define DECIMAL32_Bytes 4 /* length */ 4472ac97cdSTom Musta #define DECIMAL32_Pmax 7 /* maximum precision (digits) */ 4572ac97cdSTom Musta #define DECIMAL32_Emax 96 /* maximum adjusted exponent */ 4672ac97cdSTom Musta #define DECIMAL32_Emin -95 /* minimum adjusted exponent */ 4772ac97cdSTom Musta #define DECIMAL32_Bias 101 /* bias for the exponent */ 4872ac97cdSTom Musta #define DECIMAL32_String 15 /* maximum string length, +1 */ 4972ac97cdSTom Musta #define DECIMAL32_EconL 6 /* exp. continuation length */ 5072ac97cdSTom Musta /* highest biased exponent (Elimit-1) */ 5172ac97cdSTom Musta #define DECIMAL32_Ehigh (DECIMAL32_Emax+DECIMAL32_Bias-DECIMAL32_Pmax+1) 5272ac97cdSTom Musta 5372ac97cdSTom Musta /* check enough digits, if pre-defined */ 5472ac97cdSTom Musta #if defined(DECNUMDIGITS) 5572ac97cdSTom Musta #if (DECNUMDIGITS<DECIMAL32_Pmax) 5672ac97cdSTom Musta #error decimal32.h needs pre-defined DECNUMDIGITS>=7 for safe use 5772ac97cdSTom Musta #endif 5872ac97cdSTom Musta #endif 5972ac97cdSTom Musta 6072ac97cdSTom Musta #ifndef DECNUMDIGITS 6172ac97cdSTom Musta #define DECNUMDIGITS DECIMAL32_Pmax /* size if not already defined*/ 6272ac97cdSTom Musta #endif 630f2d3732STom Musta #include "libdecnumber/decNumber.h" 6472ac97cdSTom Musta 6572ac97cdSTom Musta /* Decimal 32-bit type, accessible by bytes */ 6672ac97cdSTom Musta typedef struct { 6772ac97cdSTom Musta uint8_t bytes[DECIMAL32_Bytes]; /* decimal32: 1, 5, 6, 20 bits*/ 6872ac97cdSTom Musta } decimal32; 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 /* ---------------------------------------------------------------- */ 7972ac97cdSTom Musta /* Routines */ 8072ac97cdSTom Musta /* ---------------------------------------------------------------- */ 8172ac97cdSTom Musta 8272ac97cdSTom Musta 8372ac97cdSTom Musta /* String conversions */ 8472ac97cdSTom Musta decimal32 * decimal32FromString(decimal32 *, const char *, decContext *); 8572ac97cdSTom Musta char * decimal32ToString(const decimal32 *, char *); 8672ac97cdSTom Musta char * decimal32ToEngString(const decimal32 *, char *); 8772ac97cdSTom Musta 8872ac97cdSTom Musta /* decNumber conversions */ 8972ac97cdSTom Musta decimal32 * decimal32FromNumber(decimal32 *, const decNumber *, 9072ac97cdSTom Musta decContext *); 9172ac97cdSTom Musta decNumber * decimal32ToNumber(const decimal32 *, decNumber *); 9272ac97cdSTom Musta 9372ac97cdSTom Musta /* Format-dependent utilities */ 9472ac97cdSTom Musta uint32_t decimal32IsCanonical(const decimal32 *); 9572ac97cdSTom Musta decimal32 * decimal32Canonical(decimal32 *, const decimal32 *); 9672ac97cdSTom Musta 9772ac97cdSTom Musta #endif 98