root/src/decNumber/decQuad.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: d4c85f73-f62c-11ec-a704-80ee73e9b8e7
   4 /* ------------------------------------------------------------------ */
   5 /* decQuad.h -- Decimal 128-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             */
  10 /* ICU License -- ICU 1.8.1 and later.                                */
  11 /*                                                                    */
  12 /* The description and User's Guide ("The decNumber C Library") for   */
  13 /* this software is included in the package as decNumber.pdf.  This   */
  14 /* document is also available in HTML, together with specifications,  */
  15 /* testcases, and Web links, on the General Decimal Arithmetic page.  */
  16 /*                                                                    */
  17 /* Please send comments, suggestions, and corrections to the author:  */
  18 /*   mfc@uk.ibm.com                                                   */
  19 /*   Mike Cowlishaw, IBM Fellow                                       */
  20 /*   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         */
  21 /* ------------------------------------------------------------------ */
  22 /* This include file is always included by decSingle and decDouble,   */
  23 /* and therefore also holds useful constants used by all three.       */
  24 
  25 #if !defined(DECQUAD)
  26 # define DECQUAD
  27 
  28 # define DECQUADNAME         "decimalQuad"            /* Short name   */
  29 # define DECQUADTITLE        "Decimal 128-bit datum"  /* Verbose name */
  30 # define DECQUADAUTHOR       "Mike Cowlishaw"         /* Who to blame */
  31 
  32   /* parameters for decQuads */
  33 # define DECQUAD_Bytes    16       /* length                          */
  34 # define DECQUAD_Pmax     34       /* maximum precision (digits)      */
  35 # define DECQUAD_Emin  -6143       /* minimum adjusted exponent       */
  36 # define DECQUAD_Emax   6144       /* maximum adjusted exponent       */
  37 # define DECQUAD_EmaxD     4       /* maximum exponent digits         */
  38 # define DECQUAD_Bias   6176       /* bias for the exponent           */
  39 # define DECQUAD_String   43       /* maximum string length, +1       */
  40 # define DECQUAD_EconL    12       /* exponent continuation length    */
  41 # define DECQUAD_Declets  11       /* count of declets                */
  42   /* highest biased exponent (Elimit-1) */
  43 # define DECQUAD_Ehigh (DECQUAD_Emax + DECQUAD_Bias - (DECQUAD_Pmax-1))
  44 
  45   /* Required include                                                 */
  46 # include "decContext.h"
  47 
  48   /* The decQuad decimal 128-bit type, accessible by all sizes */
  49   typedef union {
  50     uint8_t   bytes[DECQUAD_Bytes];     /* fields: 1, 5, 12, 110 bits */
  51     uint16_t shorts[DECQUAD_Bytes/2];
  52     uint32_t  words[DECQUAD_Bytes/4];
  53 # if DECUSE64
  54     uint64_t  longs[DECQUAD_Bytes/8];
  55 # endif
  56     } decQuad;
  57 
  58   /* ---------------------------------------------------------------- */
  59   /* Shared constants                                                 */
  60   /* ---------------------------------------------------------------- */
  61 
  62   /* sign and special values [top 32-bits; last two bits are don't-care
  63      for Infinity on input, last bit don't-care for NaNs] */
  64 # define DECFLOAT_Sign  0x80000000      /* 1 00000 00 Sign            */
  65 # define DECFLOAT_NaN   0x7c000000      /* 0 11111 00 NaN generic     */
  66 # define DECFLOAT_qNaN  0x7c000000      /* 0 11111 00 qNaN            */
  67 # define DECFLOAT_sNaN  0x7e000000      /* 0 11111 10 sNaN            */
  68 # define DECFLOAT_Inf   0x78000000      /* 0 11110 00 Infinity        */
  69 # define DECFLOAT_MinSp 0x78000000      /* minimum special value      */
  70                                         /* [specials are all >=MinSp] */
  71   /* Sign nibble constants                                            */
  72 # if !defined(DECPPLUSALT)
  73 #  define DECPPLUSALT  0x0A   /* alternate plus  nibble               */
  74 #  define DECPMINUSALT 0x0B   /* alternate minus nibble               */
  75 #  define DECPPLUS     0x0C   /* preferred plus  nibble               */
  76 #  define DECPMINUS    0x0D   /* preferred minus nibble               */
  77 #  define DECPPLUSALT2 0x0E   /* alternate plus  nibble               */
  78 #  define DECPUNSIGNED 0x0F   /* alternate plus  nibble (unsigned)    */
  79 # endif
  80 
  81   /* ---------------------------------------------------------------- */
  82   /* Routines -- implemented as decFloat routines in common files     */
  83   /* ---------------------------------------------------------------- */
  84 
  85   /* Utilities and conversions, extractors, etc.) */
  86   extern decQuad * decQuadFromBCD(decQuad *, int32_t, const uint8_t *, int32_t);
  87   extern decQuad * decQuadFromInt32(decQuad *, int32_t);
  88   extern decQuad * decQuadFromPacked(decQuad *, int32_t, const uint8_t *);
  89   extern decQuad * decQuadFromPackedChecked(decQuad *, int32_t, const uint8_t *);
  90   extern decQuad * decQuadFromString(decQuad *, const char *, decContext *);
  91   extern decQuad * decQuadFromUInt32(decQuad *, uint32_t);
  92   extern int32_t   decQuadGetCoefficient(const decQuad *, uint8_t *);
  93   extern int32_t   decQuadGetExponent(const decQuad *);
  94   extern decQuad * decQuadSetCoefficient(decQuad *, const uint8_t *, int32_t);
  95   extern decQuad * decQuadSetExponent(decQuad *, decContext *, int32_t);
  96   extern void      decQuadShow(const decQuad *, const char *);
  97   extern int32_t   decQuadToBCD(const decQuad *, int32_t *, uint8_t *);
  98   extern char    * decQuadToEngString(const decQuad *, char *);
  99   extern int32_t   decQuadToInt32(const decQuad *, decContext *, enum rounding);
 100   extern int32_t   decQuadToInt32Exact(const decQuad *, decContext *, enum rounding);
 101   extern int32_t   decQuadToPacked(const decQuad *, int32_t *, uint8_t *);
 102   extern char    * decQuadToString(const decQuad *, char *);
 103   extern uint32_t  decQuadToUInt32(const decQuad *, decContext *, enum rounding);
 104   extern uint32_t  decQuadToUInt32Exact(const decQuad *, decContext *, enum rounding);
 105   extern decQuad * decQuadZero(decQuad *);
 106 
 107   /* Computational (result is a decQuad) */
 108   extern decQuad * decQuadAbs(decQuad *, const decQuad *, decContext *);
 109   extern decQuad * decQuadAdd(decQuad *, const decQuad *, const decQuad *, decContext *);
 110   extern decQuad * decQuadAnd(decQuad *, const decQuad *, const decQuad *, decContext *);
 111   extern decQuad * decQuadDivide(decQuad *, const decQuad *, const decQuad *, decContext *);
 112   extern decQuad * decQuadDivideInteger(decQuad *, const decQuad *, const decQuad *, decContext *);
 113   extern decQuad * decQuadFMA(decQuad *, const decQuad *, const decQuad *, const decQuad *, decContext *);
 114   extern decQuad * decQuadInvert(decQuad *, const decQuad *, decContext *);
 115   extern decQuad * decQuadLogB(decQuad *, const decQuad *, decContext *);
 116   extern decQuad * decQuadMax(decQuad *, const decQuad *, const decQuad *, decContext *);
 117   extern decQuad * decQuadMaxMag(decQuad *, const decQuad *, const decQuad *, decContext *);
 118   extern decQuad * decQuadMin(decQuad *, const decQuad *, const decQuad *, decContext *);
 119   extern decQuad * decQuadMinMag(decQuad *, const decQuad *, const decQuad *, decContext *);
 120   extern decQuad * decQuadMinus(decQuad *, const decQuad *, decContext *);
 121   extern decQuad * decQuadMultiply(decQuad *, const decQuad *, const decQuad *, decContext *);
 122   extern decQuad * decQuadNextMinus(decQuad *, const decQuad *, decContext *);
 123   extern decQuad * decQuadNextPlus(decQuad *, const decQuad *, decContext *);
 124   extern decQuad * decQuadNextToward(decQuad *, const decQuad *, const decQuad *, decContext *);
 125   extern decQuad * decQuadOr(decQuad *, const decQuad *, const decQuad *, decContext *);
 126   extern decQuad * decQuadPlus(decQuad *, const decQuad *, decContext *);
 127   extern decQuad * decQuadQuantize(decQuad *, const decQuad *, const decQuad *, decContext *);
 128   extern decQuad * decQuadReduce(decQuad *, const decQuad *, decContext *);
 129   extern decQuad * decQuadRemainder(decQuad *, const decQuad *, const decQuad *, decContext *);
 130   extern decQuad * decQuadRemainderNear(decQuad *, const decQuad *, const decQuad *, decContext *);
 131   extern decQuad * decQuadRotate(decQuad *, const decQuad *, const decQuad *, decContext *);
 132   extern decQuad * decQuadScaleB(decQuad *, const decQuad *, const decQuad *, decContext *);
 133   extern decQuad * decQuadShift(decQuad *, const decQuad *, const decQuad *, decContext *);
 134   extern decQuad * decQuadSubtract(decQuad *, const decQuad *, const decQuad *, decContext *);
 135   extern decQuad * decQuadToIntegralValue(decQuad *, const decQuad *, decContext *, enum rounding);
 136   extern decQuad * decQuadToIntegralExact(decQuad *, const decQuad *, decContext *);
 137   extern decQuad * decQuadXor(decQuad *, const decQuad *, const decQuad *, decContext *);
 138 
 139   /* Comparisons */
 140   extern decQuad * decQuadCompare(decQuad *, const decQuad *, const decQuad *, decContext *);
 141   extern decQuad * decQuadCompareSignal(decQuad *, const decQuad *, const decQuad *, decContext *);
 142   extern decQuad * decQuadCompareTotal(decQuad *, const decQuad *, const decQuad *);
 143   extern decQuad * decQuadCompareTotalMag(decQuad *, const decQuad *, const decQuad *);
 144 
 145   /* Copies */
 146   extern decQuad * decQuadCanonical(decQuad *, const decQuad *);
 147   extern decQuad * decQuadCopy(decQuad *, const decQuad *);
 148   extern decQuad * decQuadCopyAbs(decQuad *, const decQuad *);
 149   extern decQuad * decQuadCopyNegate(decQuad *, const decQuad *);
 150   extern decQuad * decQuadCopySign(decQuad *, const decQuad *, const decQuad *);
 151 
 152   /* Non-computational */
 153   extern enum decClass decQuadClass(const decQuad *);
 154   extern const char *  decQuadClassString(const decQuad *);
 155   extern uint32_t      decQuadDigits(const decQuad *);
 156   extern uint32_t      decQuadIsCanonical(const decQuad *);
 157   extern uint32_t      decQuadIsFinite(const decQuad *);
 158   extern uint32_t      decQuadIsInteger(const decQuad *);
 159   extern uint32_t      decQuadIsLogical(const decQuad *);
 160   extern uint32_t      decQuadIsInfinite(const decQuad *);
 161   extern uint32_t      decQuadIsNaN(const decQuad *);
 162   extern uint32_t      decQuadIsNegative(const decQuad *);
 163   extern uint32_t      decQuadIsNormal(const decQuad *);
 164   extern uint32_t      decQuadIsPositive(const decQuad *);
 165   extern uint32_t      decQuadIsSignaling(const decQuad *);
 166   extern uint32_t      decQuadIsSignalling(const decQuad *);
 167   extern uint32_t      decQuadIsSigned(const decQuad *);
 168   extern uint32_t      decQuadIsSubnormal(const decQuad *);
 169   extern uint32_t      decQuadIsZero(const decQuad *);
 170   extern uint32_t      decQuadRadix(const decQuad *);
 171   extern uint32_t      decQuadSameQuantum(const decQuad *, const decQuad *);
 172   extern const char *  decQuadVersion(void);
 173 
 174   /* decNumber conversions; these are implemented as macros so as not  */
 175   /* to force a dependency on decimal128 and decNumber in decQuad.     */
 176   /* decQuadFromNumber returns a decimal128 * to avoid warnings.       */
 177 # define decQuadToNumber(dq, dn) \
 178     decimal128ToNumber((decimal128 *)(dq), dn)
 179 # define decQuadFromNumber(dq, dn, set) \
 180     decimal128FromNumber((decimal128 *)(dq), dn, set)
 181 
 182 #endif

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