Home | History | Annotate | Line # | Download | only in dpd
      1       1.1  mrg /* Decimal 64-bit format module header for the decNumber C Library.
      2  1.1.1.12  mrg    Copyright (C) 2005-2024 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 64-bit format module header				      */
     28       1.1  mrg /* ------------------------------------------------------------------ */
     29       1.1  mrg 
     30       1.1  mrg #if !defined(DECIMAL64)
     31       1.1  mrg   #define DECIMAL64
     32       1.1  mrg   #define DEC64NAME	"decimal64"		      /* Short name   */
     33       1.1  mrg   #define DEC64FULLNAME "Decimal 64-bit Number"       /* Verbose name */
     34       1.1  mrg   #define DEC64AUTHOR	"Mike Cowlishaw"	      /* Who to blame */
     35       1.1  mrg 
     36       1.1  mrg 
     37       1.1  mrg   /* parameters for decimal64s					      */
     38       1.1  mrg   #define DECIMAL64_Bytes  8		/* length		      */
     39       1.1  mrg   #define DECIMAL64_Pmax   16		/* maximum precision (digits) */
     40       1.1  mrg   #define DECIMAL64_Emax   384		/* maximum adjusted exponent  */
     41       1.1  mrg   #define DECIMAL64_Emin  -383		/* minimum adjusted exponent  */
     42       1.1  mrg   #define DECIMAL64_Bias   398		/* bias for the exponent      */
     43       1.1  mrg   #define DECIMAL64_String 24		/* maximum string length, +1  */
     44       1.1  mrg   #define DECIMAL64_EconL  8		/* exp. continuation length   */
     45       1.1  mrg   /* highest biased exponent (Elimit-1) 			      */
     46       1.1  mrg   #define DECIMAL64_Ehigh  (DECIMAL64_Emax+DECIMAL64_Bias-DECIMAL64_Pmax+1)
     47       1.1  mrg 
     48       1.1  mrg   /* check enough digits, if pre-defined			      */
     49       1.1  mrg   #if defined(DECNUMDIGITS)
     50       1.1  mrg     #if (DECNUMDIGITS<DECIMAL64_Pmax)
     51       1.1  mrg       #error decimal64.h needs pre-defined DECNUMDIGITS>=16 for safe use
     52       1.1  mrg     #endif
     53       1.1  mrg   #endif
     54       1.1  mrg 
     55       1.1  mrg 
     56       1.1  mrg   #ifndef DECNUMDIGITS
     57       1.1  mrg     #define DECNUMDIGITS DECIMAL64_Pmax /* size if not already defined*/
     58       1.1  mrg   #endif
     59       1.1  mrg   #ifndef DECNUMBER
     60       1.1  mrg     #include "decNumber.h"		/* context and number library */
     61       1.1  mrg   #endif
     62       1.1  mrg 
     63       1.1  mrg   /* Decimal 64-bit type, accessible by bytes			      */
     64       1.1  mrg   typedef struct {
     65       1.1  mrg     uint8_t bytes[DECIMAL64_Bytes];	/* decimal64: 1, 5, 8, 50 bits*/
     66       1.1  mrg     } decimal64;
     67       1.1  mrg 
     68       1.1  mrg   /* special values [top byte excluding sign bit; last two bits are   */
     69       1.1  mrg   /* don't-care for Infinity on input, last bit don't-care for NaN]   */
     70       1.1  mrg   #if !defined(DECIMAL_NaN)
     71       1.1  mrg     #define DECIMAL_NaN     0x7c	/* 0 11111 00 NaN	      */
     72       1.1  mrg     #define DECIMAL_sNaN    0x7e	/* 0 11111 10 sNaN	      */
     73       1.1  mrg     #define DECIMAL_Inf     0x78	/* 0 11110 00 Infinity	      */
     74       1.1  mrg   #endif
     75       1.1  mrg 
     76       1.1  mrg   /* ---------------------------------------------------------------- */
     77       1.1  mrg   /* Routines							      */
     78       1.1  mrg   /* ---------------------------------------------------------------- */
     79       1.1  mrg 
     80       1.1  mrg #include "decimal64Symbols.h"
     81       1.1  mrg 
     82       1.1  mrg   #ifdef __cplusplus
     83       1.1  mrg   extern "C" {
     84       1.1  mrg   #endif
     85       1.1  mrg 
     86       1.1  mrg   /* String conversions 					      */
     87       1.1  mrg   decimal64 * decimal64FromString(decimal64 *, const char *, decContext *);
     88       1.1  mrg   char * decimal64ToString(const decimal64 *, char *);
     89       1.1  mrg   char * decimal64ToEngString(const decimal64 *, char *);
     90       1.1  mrg 
     91       1.1  mrg   /* decNumber conversions					      */
     92       1.1  mrg   decimal64 * decimal64FromNumber(decimal64 *, const decNumber *,
     93       1.1  mrg 				  decContext *);
     94       1.1  mrg   decNumber * decimal64ToNumber(const decimal64 *, decNumber *);
     95       1.1  mrg 
     96       1.1  mrg   /* Format-dependent utilities 				      */
     97       1.1  mrg   uint32_t    decimal64IsCanonical(const decimal64 *);
     98       1.1  mrg   decimal64 * decimal64Canonical(decimal64 *, const decimal64 *);
     99       1.1  mrg 
    100       1.1  mrg   #ifdef __cplusplus
    101       1.1  mrg   }
    102       1.1  mrg   #endif
    103       1.1  mrg 
    104       1.1  mrg #endif
    105