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

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