Home | History | Annotate | Line # | Download | only in dpd
      1   1.1  mrg /* Decimal 32-bit format module header for the decNumber C Library.
      2  1.12  mrg    Copyright (C) 2005-2022 Free Software Foundation, Inc.
      3   1.1  mrg    Contributed by IBM Corporation.  Author Mike Cowlishaw.
      4   1.1  mrg 
      5   1.1  mrg    This file is part of GCC.
      6   1.1  mrg 
      7   1.1  mrg    GCC is free software; you can redistribute it and/or modify it under
      8   1.1  mrg    the terms of the GNU General Public License as published by the Free
      9   1.1  mrg    Software Foundation; either version 3, or (at your option) any later
     10   1.1  mrg    version.
     11   1.1  mrg 
     12   1.1  mrg    GCC is distributed in the hope that it will be useful, but WITHOUT ANY
     13   1.1  mrg    WARRANTY; without even the implied warranty of MERCHANTABILITY or
     14   1.1  mrg    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
     15   1.1  mrg    for more details.
     16   1.1  mrg 
     17   1.1  mrg Under Section 7 of GPL version 3, you are granted additional
     18   1.1  mrg permissions described in the GCC Runtime Library Exception, version
     19   1.1  mrg 3.1, as published by the Free Software Foundation.
     20   1.1  mrg 
     21   1.1  mrg You should have received a copy of the GNU General Public License and
     22   1.1  mrg a copy of the GCC Runtime Library Exception along with this program;
     23   1.1  mrg see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
     24   1.1  mrg <http://www.gnu.org/licenses/>.  */
     25   1.1  mrg 
     26   1.1  mrg /* ------------------------------------------------------------------ */
     27   1.1  mrg /* Decimal 32-bit format module header				      */
     28   1.1  mrg /* ------------------------------------------------------------------ */
     29   1.1  mrg 
     30   1.1  mrg #if !defined(DECIMAL32)
     31   1.1  mrg   #define DECIMAL32
     32   1.1  mrg   #define DEC32NAME	"decimal32"		      /* Short name   */
     33   1.1  mrg   #define DEC32FULLNAME "Decimal 32-bit Number"       /* Verbose name */
     34   1.1  mrg   #define DEC32AUTHOR	"Mike Cowlishaw"	      /* Who to blame */
     35   1.1  mrg 
     36   1.1  mrg   /* parameters for decimal32s */
     37   1.1  mrg   #define DECIMAL32_Bytes  4		/* length		      */
     38   1.1  mrg   #define DECIMAL32_Pmax   7		/* maximum precision (digits) */
     39   1.1  mrg   #define DECIMAL32_Emax   96		/* maximum adjusted exponent  */
     40   1.1  mrg   #define DECIMAL32_Emin  -95		/* minimum adjusted exponent  */
     41   1.1  mrg   #define DECIMAL32_Bias   101		/* bias for the exponent      */
     42   1.1  mrg   #define DECIMAL32_String 15		/* maximum string length, +1  */
     43   1.1  mrg   #define DECIMAL32_EconL  6		/* exp. continuation length   */
     44   1.1  mrg   /* highest biased exponent (Elimit-1) 			      */
     45   1.1  mrg   #define DECIMAL32_Ehigh  (DECIMAL32_Emax+DECIMAL32_Bias-DECIMAL32_Pmax+1)
     46   1.1  mrg 
     47   1.1  mrg   /* check enough digits, if pre-defined			      */
     48   1.1  mrg   #if defined(DECNUMDIGITS)
     49   1.1  mrg     #if (DECNUMDIGITS<DECIMAL32_Pmax)
     50   1.1  mrg       #error decimal32.h needs pre-defined DECNUMDIGITS>=7 for safe use
     51   1.1  mrg     #endif
     52   1.1  mrg   #endif
     53   1.1  mrg 
     54   1.1  mrg   #ifndef DECNUMDIGITS
     55   1.1  mrg     #define DECNUMDIGITS DECIMAL32_Pmax /* size if not already defined*/
     56   1.1  mrg   #endif
     57   1.1  mrg   #ifndef DECNUMBER
     58   1.1  mrg     #include "decNumber.h"		/* context and number library */
     59   1.1  mrg   #endif
     60   1.1  mrg 
     61   1.1  mrg   /* Decimal 32-bit type, accessible by bytes */
     62   1.1  mrg   typedef struct {
     63   1.1  mrg     uint8_t bytes[DECIMAL32_Bytes];	/* decimal32: 1, 5, 6, 20 bits*/
     64   1.1  mrg     } decimal32;
     65   1.1  mrg 
     66   1.1  mrg   /* special values [top byte excluding sign bit; last two bits are   */
     67   1.1  mrg   /* don't-care for Infinity on input, last bit don't-care for NaN]   */
     68   1.1  mrg   #if !defined(DECIMAL_NaN)
     69   1.1  mrg     #define DECIMAL_NaN     0x7c	/* 0 11111 00 NaN	      */
     70   1.1  mrg     #define DECIMAL_sNaN    0x7e	/* 0 11111 10 sNaN	      */
     71   1.1  mrg     #define DECIMAL_Inf     0x78	/* 0 11110 00 Infinity	      */
     72   1.1  mrg   #endif
     73   1.1  mrg 
     74   1.1  mrg   /* ---------------------------------------------------------------- */
     75   1.1  mrg   /* Routines							      */
     76   1.1  mrg   /* ---------------------------------------------------------------- */
     77   1.1  mrg 
     78   1.1  mrg #include "decimal32Symbols.h"
     79   1.1  mrg 
     80   1.1  mrg   #ifdef __cplusplus
     81   1.1  mrg   extern "C" {
     82   1.1  mrg   #endif
     83   1.1  mrg 
     84   1.1  mrg   /* String conversions 					      */
     85   1.1  mrg   decimal32 * decimal32FromString(decimal32 *, const char *, decContext *);
     86   1.1  mrg   char * decimal32ToString(const decimal32 *, char *);
     87   1.1  mrg   char * decimal32ToEngString(const decimal32 *, char *);
     88   1.1  mrg 
     89   1.1  mrg   /* decNumber conversions					      */
     90   1.1  mrg   decimal32 * decimal32FromNumber(decimal32 *, const decNumber *,
     91   1.1  mrg 				  decContext *);
     92   1.1  mrg   decNumber * decimal32ToNumber(const decimal32 *, decNumber *);
     93   1.1  mrg 
     94   1.1  mrg   /* Format-dependent utilities 				      */
     95   1.1  mrg   uint32_t    decimal32IsCanonical(const decimal32 *);
     96   1.1  mrg   decimal32 * decimal32Canonical(decimal32 *, const decimal32 *);
     97   1.1  mrg 
     98   1.1  mrg   #ifdef __cplusplus
     99   1.1  mrg   }
    100   1.1  mrg   #endif
    101   1.1  mrg 
    102   1.1  mrg #endif
    103