root/src/decNumber/decDouble.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


   1 // vim: filetype=c:tabstop=4:ai:expandtab
   2 // SPDX-License-Identifier: ICU
   3 // scspell-id: ad2b23cb-f62c-11ec-b35c-80ee73e9b8e7
   4 /* ------------------------------------------------------------------- */
   5 /* decDouble.h -- Decimal 64-bit format module header                  */
   6 /* ------------------------------------------------------------------- */
   7 /* Copyright (c) IBM Corporation, 2000, 2010.  All rights reserved.    */
   8 /*                                                                     */
   9 /* This software is made available under the terms of the ICU License. */
  10 /*                                                                     */
  11 /* The description and User's Guide ("The decNumber C Library") for    */
  12 /* this software is included in the package as decNumber.pdf.  This    */
  13 /* document is also available in HTML, together with specifications,   */
  14 /* testcases, and Web links, on the General Decimal Arithmetic page.   */
  15 /*                                                                     */
  16 /* Please send comments, suggestions, and corrections to the author:   */
  17 /*   mfc@uk.ibm.com                                                    */
  18 /*   Mike Cowlishaw, IBM Fellow                                        */
  19 /*   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK          */
  20 /* ------------------------------------------------------------------- */
  21 
  22 #if !defined(DECDOUBLE)
  23 # define DECDOUBLE
  24 
  25 # define DECDOUBLENAME       "decimalDouble"          /* Short name   */
  26 # define DECDOUBLETITLE      "Decimal 64-bit datum"   /* Verbose name */
  27 # define DECDOUBLEAUTHOR     "Mike Cowlishaw"         /* Who to blame */
  28 
  29   /* parameters for decDoubles */
  30 # define DECDOUBLE_Bytes   8       /* length                          */
  31 # define DECDOUBLE_Pmax    16      /* maximum precision (digits)      */
  32 # define DECDOUBLE_Emin   -383     /* minimum adjusted exponent       */
  33 # define DECDOUBLE_Emax    384     /* maximum adjusted exponent       */
  34 # define DECDOUBLE_EmaxD   3       /* maximum exponent digits         */
  35 # define DECDOUBLE_Bias    398     /* bias for the exponent           */
  36 # define DECDOUBLE_String  25      /* maximum string length, +1       */
  37 # define DECDOUBLE_EconL   8       /* exponent continuation length    */
  38 # define DECDOUBLE_Declets 5       /* count of declets                */
  39   /* highest biased exponent (Elimit-1) */
  40 # define DECDOUBLE_Ehigh (DECDOUBLE_Emax + DECDOUBLE_Bias - (DECDOUBLE_Pmax-1))
  41 
  42   /* Required includes                                                */
  43 # include "decContext.h"
  44 # include "decQuad.h"
  45 
  46   /* The decDouble decimal 64-bit type, accessible by all sizes */
  47   typedef union {
  48     uint8_t   bytes[DECDOUBLE_Bytes];   /* fields: 1, 5, 8, 50 bits */
  49     uint16_t shorts[DECDOUBLE_Bytes/2];
  50     uint32_t  words[DECDOUBLE_Bytes/4];
  51 # if DECUSE64
  52     uint64_t  longs[DECDOUBLE_Bytes/8];
  53 # endif
  54     } decDouble;
  55 
  56   /* ---------------------------------------------------------------- */
  57   /* Routines -- implemented as decFloat routines in common files     */
  58   /* ---------------------------------------------------------------- */
  59 
  60   /* Utilities and conversions, extractors, etc.) */
  61   extern decDouble * decDoubleFromBCD(decDouble *, int32_t, const uint8_t *, int32_t);
  62   extern decDouble * decDoubleFromInt32(decDouble *, int32_t);
  63   extern decDouble * decDoubleFromPacked(decDouble *, int32_t, const uint8_t *);
  64   extern decDouble * decDoubleFromPackedChecked(decDouble *, int32_t, const uint8_t *);
  65   extern decDouble * decDoubleFromString(decDouble *, const char *, decContext *);
  66   extern decDouble * decDoubleFromUInt32(decDouble *, uint32_t);
  67   extern decDouble * decDoubleFromWider(decDouble *, const decQuad *, decContext *);
  68   extern int32_t     decDoubleGetCoefficient(const decDouble *, uint8_t *);
  69   extern int32_t     decDoubleGetExponent(const decDouble *);
  70   extern decDouble * decDoubleSetCoefficient(decDouble *, const uint8_t *, int32_t);
  71   extern decDouble * decDoubleSetExponent(decDouble *, decContext *, int32_t);
  72   extern void        decDoubleShow(const decDouble *, const char *);
  73   extern int32_t     decDoubleToBCD(const decDouble *, int32_t *, uint8_t *);
  74   extern char      * decDoubleToEngString(const decDouble *, char *);
  75   extern int32_t     decDoubleToInt32(const decDouble *, decContext *, enum rounding);
  76   extern int32_t     decDoubleToInt32Exact(const decDouble *, decContext *, enum rounding);
  77   extern int32_t     decDoubleToPacked(const decDouble *, int32_t *, uint8_t *);
  78   extern char      * decDoubleToString(const decDouble *, char *);
  79   extern uint32_t    decDoubleToUInt32(const decDouble *, decContext *, enum rounding);
  80   extern uint32_t    decDoubleToUInt32Exact(const decDouble *, decContext *, enum rounding);
  81   extern decQuad   * decDoubleToWider(const decDouble *, decQuad *);
  82   extern decDouble * decDoubleZero(decDouble *);
  83 
  84   /* Computational (result is a decDouble) */
  85   extern decDouble * decDoubleAbs(decDouble *, const decDouble *, decContext *);
  86   extern decDouble * decDoubleAdd(decDouble *, const decDouble *, const decDouble *, decContext *);
  87   extern decDouble * decDoubleAnd(decDouble *, const decDouble *, const decDouble *, decContext *);
  88   extern decDouble * decDoubleDivide(decDouble *, const decDouble *, const decDouble *, decContext *);
  89   extern decDouble * decDoubleDivideInteger(decDouble *, const decDouble *, const decDouble *, decContext *);
  90   extern decDouble * decDoubleFMA(decDouble *, const decDouble *, const decDouble *, const decDouble *, decContext *);
  91   extern decDouble * decDoubleInvert(decDouble *, const decDouble *, decContext *);
  92   extern decDouble * decDoubleLogB(decDouble *, const decDouble *, decContext *);
  93   extern decDouble * decDoubleMax(decDouble *, const decDouble *, const decDouble *, decContext *);
  94   extern decDouble * decDoubleMaxMag(decDouble *, const decDouble *, const decDouble *, decContext *);
  95   extern decDouble * decDoubleMin(decDouble *, const decDouble *, const decDouble *, decContext *);
  96   extern decDouble * decDoubleMinMag(decDouble *, const decDouble *, const decDouble *, decContext *);
  97   extern decDouble * decDoubleMinus(decDouble *, const decDouble *, decContext *);
  98   extern decDouble * decDoubleMultiply(decDouble *, const decDouble *, const decDouble *, decContext *);
  99   extern decDouble * decDoubleNextMinus(decDouble *, const decDouble *, decContext *);
 100   extern decDouble * decDoubleNextPlus(decDouble *, const decDouble *, decContext *);
 101   extern decDouble * decDoubleNextToward(decDouble *, const decDouble *, const decDouble *, decContext *);
 102   extern decDouble * decDoubleOr(decDouble *, const decDouble *, const decDouble *, decContext *);
 103   extern decDouble * decDoublePlus(decDouble *, const decDouble *, decContext *);
 104   extern decDouble * decDoubleQuantize(decDouble *, const decDouble *, const decDouble *, decContext *);
 105   extern decDouble * decDoubleReduce(decDouble *, const decDouble *, decContext *);
 106   extern decDouble * decDoubleRemainder(decDouble *, const decDouble *, const decDouble *, decContext *);
 107   extern decDouble * decDoubleRemainderNear(decDouble *, const decDouble *, const decDouble *, decContext *);
 108   extern decDouble * decDoubleRotate(decDouble *, const decDouble *, const decDouble *, decContext *);
 109   extern decDouble * decDoubleScaleB(decDouble *, const decDouble *, const decDouble *, decContext *);
 110   extern decDouble * decDoubleShift(decDouble *, const decDouble *, const decDouble *, decContext *);
 111   extern decDouble * decDoubleSubtract(decDouble *, const decDouble *, const decDouble *, decContext *);
 112   extern decDouble * decDoubleToIntegralValue(decDouble *, const decDouble *, decContext *, enum rounding);
 113   extern decDouble * decDoubleToIntegralExact(decDouble *, const decDouble *, decContext *);
 114   extern decDouble * decDoubleXor(decDouble *, const decDouble *, const decDouble *, decContext *);
 115 
 116   /* Comparisons */
 117   extern decDouble * decDoubleCompare(decDouble *, const decDouble *, const decDouble *, decContext *);
 118   extern decDouble * decDoubleCompareSignal(decDouble *, const decDouble *, const decDouble *, decContext *);
 119   extern decDouble * decDoubleCompareTotal(decDouble *, const decDouble *, const decDouble *);
 120   extern decDouble * decDoubleCompareTotalMag(decDouble *, const decDouble *, const decDouble *);
 121 
 122   /* Copies */
 123   extern decDouble * decDoubleCanonical(decDouble *, const decDouble *);
 124   extern decDouble * decDoubleCopy(decDouble *, const decDouble *);
 125   extern decDouble * decDoubleCopyAbs(decDouble *, const decDouble *);
 126   extern decDouble * decDoubleCopyNegate(decDouble *, const decDouble *);
 127   extern decDouble * decDoubleCopySign(decDouble *, const decDouble *, const decDouble *);
 128 
 129   /* Non-computational */
 130   extern enum decClass decDoubleClass(const decDouble *);
 131   extern const char *  decDoubleClassString(const decDouble *);
 132   extern uint32_t      decDoubleDigits(const decDouble *);
 133   extern uint32_t      decDoubleIsCanonical(const decDouble *);
 134   extern uint32_t      decDoubleIsFinite(const decDouble *);
 135   extern uint32_t      decDoubleIsInfinite(const decDouble *);
 136   extern uint32_t      decDoubleIsInteger(const decDouble *);
 137   extern uint32_t      decDoubleIsLogical(const decDouble *);
 138   extern uint32_t      decDoubleIsNaN(const decDouble *);
 139   extern uint32_t      decDoubleIsNegative(const decDouble *);
 140   extern uint32_t      decDoubleIsNormal(const decDouble *);
 141   extern uint32_t      decDoubleIsPositive(const decDouble *);
 142   extern uint32_t      decDoubleIsSignaling(const decDouble *);
 143   extern uint32_t      decDoubleIsSignalling(const decDouble *);
 144   extern uint32_t      decDoubleIsSigned(const decDouble *);
 145   extern uint32_t      decDoubleIsSubnormal(const decDouble *);
 146   extern uint32_t      decDoubleIsZero(const decDouble *);
 147   extern uint32_t      decDoubleRadix(const decDouble *);
 148   extern uint32_t      decDoubleSameQuantum(const decDouble *, const decDouble *);
 149   extern const char *  decDoubleVersion(void);
 150 
 151   /* decNumber conversions; these are implemented as macros so as not  */
 152   /* to force a dependency on decimal64 and decNumber in decDouble.    */
 153   /* decDoubleFromNumber returns a decimal64 * to avoid warnings.      */
 154 # define decDoubleToNumber(dq, dn) decimal64ToNumber((decimal64 *)(dq), dn)
 155 # define decDoubleFromNumber(dq, dn, set) decimal64FromNumber((decimal64 *)(dq), dn, set)
 156 
 157 #endif

/* [previous][next][first][last][top][bottom][index][help] */