HPGCC3 Documentation 3.0 R003

decQuad.h

Go to the documentation of this file.
00001 /* ------------------------------------------------------------------ */
00002 /* decQuad.h -- Decimal 128-bit format module header                  */
00003 /* ------------------------------------------------------------------ */
00004 /* Copyright (c) IBM Corporation, 2000, 2007.  All rights reserved.   */
00005 /*                                                                    */
00006 /* This software is made available under the terms of the             */
00007 /* ICU License -- ICU 1.8.1 and later.                                */
00008 /*                                                                    */
00009 /* Please see decFloats.h for an overview and documentation details.  */
00010 /*                                                                    */
00011 /* Please send comments, suggestions, and corrections to the author:  */
00012 /*   mfc@uk.ibm.com  (Mike Cowlishaw FREng, IBM Fellow,               */
00013 /*   IBM UK MP8, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK     */
00014 /* ------------------------------------------------------------------ */
00015 /* This include file is always included by decSingle and decDouble,   */
00016 /* and therefore also holds useful constants used by all three.       */
00017 
00018 #if !defined(DECQUAD)
00019   #define DECQUAD
00020 
00021   #define DECQUADNAME         "decimalQuad"           /* Short name   */
00022   #define DECQUADTITLE        "Decimal 128-bit datum" /* Verbose name */
00023   #define DECQUADAUTHOR       "Mike Cowlishaw"        /* Who to blame */
00024 
00025   /* parameters for decQuads */
00026   #define DECQUAD_Bytes    16      /* length                          */
00027   #define DECQUAD_Pmax     34      /* maximum precision (digits)      */
00028   #define DECQUAD_Emin  -6143      /* minimum adjusted exponent       */
00029   #define DECQUAD_Emax   6144      /* maximum adjusted exponent       */
00030   #define DECQUAD_EmaxD     4      /* maximum exponent digits         */
00031   #define DECQUAD_Bias   6176      /* bias for the exponent           */
00032   #define DECQUAD_String   43      /* maximum string length, +1       */
00033   #define DECQUAD_EconL    12      /* exponent continuation length    */
00034   #define DECQUAD_Declets  11      /* count of declets                */
00035   /* highest biased exponent (Elimit-1) */
00036   #define DECQUAD_Ehigh (DECQUAD_Emax + DECQUAD_Bias - (DECQUAD_Pmax-1))
00037 
00038   /* Required include                                                 */
00039   #include "decContext.h"
00040 
00041   /* The decQuad decimal 128-bit type, accessible by bytes */
00042   typedef struct {
00043     uint8_t bytes[DECQUAD_Bytes];  /* fields: 1, 5, 12, 110 bits */
00044     } decQuad;
00045 
00046   /* ---------------------------------------------------------------- */
00047   /* Shared constants                                                 */
00048   /* ---------------------------------------------------------------- */
00049 
00050   /* sign and special values [top 32-bits; last two bits are don't-care
00051      for Infinity on input, last bit don't-care for NaNs] */
00052   #define DECFLOAT_Sign  0x80000000     /* 1 00000 00 Sign */
00053   #define DECFLOAT_NaN   0x7c000000     /* 0 11111 00 NaN generic */
00054   #define DECFLOAT_qNaN  0x7c000000     /* 0 11111 00 qNaN */
00055   #define DECFLOAT_sNaN  0x7e000000     /* 0 11111 10 sNaN */
00056   #define DECFLOAT_Inf   0x78000000     /* 0 11110 00 Infinity */
00057   #define DECFLOAT_MinSp 0x78000000     /* minimum special value */
00058                                         /* [specials are all >=MinSp] */
00059   /* Sign nibble constants                                            */
00060   #if !defined(DECPPLUSALT)
00061     #define DECPPLUSALT  0x0A /* alternate plus  nibble               */
00062     #define DECPMINUSALT 0x0B /* alternate minus nibble               */
00063     #define DECPPLUS     0x0C /* preferred plus  nibble               */
00064     #define DECPMINUS    0x0D /* preferred minus nibble               */
00065     #define DECPPLUSALT2 0x0E /* alternate plus  nibble               */
00066     #define DECPUNSIGNED 0x0F /* alternate plus  nibble (unsigned)    */
00067   #endif
00068 
00069   /* ---------------------------------------------------------------- */
00070   /* Routines -- implemented as decFloat routines in common files     */
00071   /* ---------------------------------------------------------------- */
00072 
00073   /* Utilities and conversions, extractors, etc.) */
00074   extern decQuad * decQuadFromBCD(decQuad *, int32_t, const uint8_t *, int32_t);
00075   extern decQuad * decQuadFromInt32(decQuad *, int32_t);
00076   extern decQuad * decQuadFromPacked(decQuad *, int32_t, const uint8_t *);
00077   extern decQuad * decQuadFromString(decQuad *, const char *, decContext *);
00078   extern decQuad * decQuadFromUInt32(decQuad *, uint32_t);
00079   extern int32_t   decQuadGetCoefficient(const decQuad *, uint8_t *);
00080   extern int32_t   decQuadGetExponent(const decQuad *);
00081   extern decQuad * decQuadSetCoefficient(decQuad *, const uint8_t *, int32_t);
00082   extern decQuad * decQuadSetExponent(decQuad *, decContext *, int32_t);
00083   extern void      decQuadShow(const decQuad *, const char *);
00084   extern int32_t   decQuadToBCD(const decQuad *, int32_t *, uint8_t *);
00085   extern char    * decQuadToEngString(const decQuad *, char *);
00086   extern int32_t   decQuadToInt32(const decQuad *, decContext *, enum rounding);
00087   extern int32_t   decQuadToInt32Exact(const decQuad *, decContext *, enum rounding);
00088   extern int32_t   decQuadToPacked(const decQuad *, int32_t *, uint8_t *);
00089   extern char    * decQuadToString(const decQuad *, char *);
00090   extern uint32_t  decQuadToUInt32(const decQuad *, decContext *, enum rounding);
00091   extern uint32_t  decQuadToUInt32Exact(const decQuad *, decContext *, enum rounding);
00092   extern decQuad * decQuadZero(decQuad *);
00093 
00094   /* Computational (result is a decQuad) */
00095   extern decQuad * decQuadAbs(decQuad *, const decQuad *, decContext *);
00096   extern decQuad * decQuadAdd(decQuad *, const decQuad *, const decQuad *, decContext *);
00097   extern decQuad * decQuadAnd(decQuad *, const decQuad *, const decQuad *, decContext *);
00098   extern decQuad * decQuadDivide(decQuad *, const decQuad *, const decQuad *, decContext *);
00099   extern decQuad * decQuadDivideInteger(decQuad *, const decQuad *, const decQuad *, decContext *);
00100   extern decQuad * decQuadFMA(decQuad *, const decQuad *, const decQuad *, const decQuad *, decContext *);
00101   extern decQuad * decQuadInvert(decQuad *, const decQuad *, decContext *);
00102   extern decQuad * decQuadLogB(decQuad *, const decQuad *, decContext *);
00103   extern decQuad * decQuadMax(decQuad *, const decQuad *, const decQuad *, decContext *);
00104   extern decQuad * decQuadMaxMag(decQuad *, const decQuad *, const decQuad *, decContext *);
00105   extern decQuad * decQuadMin(decQuad *, const decQuad *, const decQuad *, decContext *);
00106   extern decQuad * decQuadMinMag(decQuad *, const decQuad *, const decQuad *, decContext *);
00107   extern decQuad * decQuadMinus(decQuad *, const decQuad *, decContext *);
00108   extern decQuad * decQuadMultiply(decQuad *, const decQuad *, const decQuad *, decContext *);
00109   extern decQuad * decQuadNextMinus(decQuad *, const decQuad *, decContext *);
00110   extern decQuad * decQuadNextPlus(decQuad *, const decQuad *, decContext *);
00111   extern decQuad * decQuadNextToward(decQuad *, const decQuad *, const decQuad *, decContext *);
00112   extern decQuad * decQuadOr(decQuad *, const decQuad *, const decQuad *, decContext *);
00113   extern decQuad * decQuadPlus(decQuad *, const decQuad *, decContext *);
00114   extern decQuad * decQuadQuantize(decQuad *, const decQuad *, const decQuad *, decContext *);
00115   extern decQuad * decQuadReduce(decQuad *, const decQuad *, decContext *);
00116   extern decQuad * decQuadRemainder(decQuad *, const decQuad *, const decQuad *, decContext *);
00117   extern decQuad * decQuadRemainderNear(decQuad *, const decQuad *, const decQuad *, decContext *);
00118   extern decQuad * decQuadRotate(decQuad *, const decQuad *, const decQuad *, decContext *);
00119   extern decQuad * decQuadScaleB(decQuad *, const decQuad *, const decQuad *, decContext *);
00120   extern decQuad * decQuadShift(decQuad *, const decQuad *, const decQuad *, decContext *);
00121   extern decQuad * decQuadSubtract(decQuad *, const decQuad *, const decQuad *, decContext *);
00122   extern decQuad * decQuadToIntegralValue(decQuad *, const decQuad *, decContext *, enum rounding);
00123   extern decQuad * decQuadToIntegralExact(decQuad *, const decQuad *, decContext *);
00124   extern decQuad * decQuadXor(decQuad *, const decQuad *, const decQuad *, decContext *);
00125 
00126   /* Comparisons */
00127   extern decQuad * decQuadCompare(decQuad *, const decQuad *, const decQuad *, decContext *);
00128   extern decQuad * decQuadCompareSignal(decQuad *, const decQuad *, const decQuad *, decContext *);
00129   extern decQuad * decQuadCompareTotal(decQuad *, const decQuad *, const decQuad *);
00130   extern decQuad * decQuadCompareTotalMag(decQuad *, const decQuad *, const decQuad *);
00131 
00132   /* Copies */
00133   extern decQuad * decQuadCanonical(decQuad *, const decQuad *);
00134   extern decQuad * decQuadCopy(decQuad *, const decQuad *);
00135   extern decQuad * decQuadCopyAbs(decQuad *, const decQuad *);
00136   extern decQuad * decQuadCopyNegate(decQuad *, const decQuad *);
00137   extern decQuad * decQuadCopySign(decQuad *, const decQuad *, const decQuad *);
00138 
00139   /* Non-computational */
00140   extern enum decClass decQuadClass(const decQuad *);
00141   extern const char *  decQuadClassString(const decQuad *);
00142   extern uint32_t      decQuadDigits(const decQuad *);
00143   extern uint32_t      decQuadIsCanonical(const decQuad *);
00144   extern uint32_t      decQuadIsFinite(const decQuad *);
00145   extern uint32_t      decQuadIsInteger(const decQuad *);
00146   extern uint32_t      decQuadIsInfinite(const decQuad *);
00147   extern uint32_t      decQuadIsNaN(const decQuad *);
00148   extern uint32_t      decQuadIsNormal(const decQuad *);
00149   extern uint32_t      decQuadIsSignaling(const decQuad *);
00150   extern uint32_t      decQuadIsSignalling(const decQuad *);
00151   extern uint32_t      decQuadIsSigned(const decQuad *);
00152   extern uint32_t      decQuadIsSubnormal(const decQuad *);
00153   extern uint32_t      decQuadIsZero(const decQuad *);
00154   extern uint32_t      decQuadRadix(const decQuad *);
00155   extern uint32_t      decQuadSameQuantum(const decQuad *, const decQuad *);
00156   extern const char *  decQuadVersion(void);
00157 
00158   /* decNumber conversions; these are implemented as macros so as not  */
00159   /* to force a dependency on decimal128 and decNumber in decQuad.     */
00160   #define decQuadToNumber(dq, dn) decimal128ToNumber((decimal128 *)(dq), dn)
00161   #define decQuadFromNumber(dq, dn, set) (decQuad *)decimal128FromNumber((decimal128 *)(dq), dn, set)
00162 
00163 #endif