HPGCC3 Documentation 3.0 R003
|
00001 /* ------------------------------------------------------------------ */ 00002 /* decDouble.h -- Decimal 64-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 00016 #if !defined(DECDOUBLE) 00017 #define DECDOUBLE 00018 00019 #define DECDOUBLENAME "decimalDouble" /* Short name */ 00020 #define DECDOUBLETITLE "Decimal 64-bit datum" /* Verbose name */ 00021 #define DECDOUBLEAUTHOR "Mike Cowlishaw" /* Who to blame */ 00022 00023 /* parameters for decDoubles */ 00024 #define DECDOUBLE_Bytes 8 /* length */ 00025 #define DECDOUBLE_Pmax 16 /* maximum precision (digits) */ 00026 #define DECDOUBLE_Emin -383 /* minimum adjusted exponent */ 00027 #define DECDOUBLE_Emax 384 /* maximum adjusted exponent */ 00028 #define DECDOUBLE_EmaxD 3 /* maximum exponent digits */ 00029 #define DECDOUBLE_Bias 398 /* bias for the exponent */ 00030 #define DECDOUBLE_String 25 /* maximum string length, +1 */ 00031 #define DECDOUBLE_EconL 8 /* exponent continuation length */ 00032 #define DECDOUBLE_Declets 5 /* count of declets */ 00033 /* highest biased exponent (Elimit-1) */ 00034 #define DECDOUBLE_Ehigh (DECDOUBLE_Emax + DECDOUBLE_Bias - (DECDOUBLE_Pmax-1)) 00035 00036 /* Required includes */ 00037 #include "decContext.h" 00038 #include "decQuad.h" 00039 00040 /* The decDouble decimal 64-bit type, accessible by bytes */ 00041 typedef struct { 00042 uint8_t bytes[DECDOUBLE_Bytes]; /* fields: 1, 5, 8, 50 bits */ 00043 } decDouble; 00044 00045 /* ---------------------------------------------------------------- */ 00046 /* Routines -- implemented as decFloat routines in common files */ 00047 /* ---------------------------------------------------------------- */ 00048 00049 /* Utilities and conversions, extractors, etc.) */ 00050 extern decDouble * decDoubleFromBCD(decDouble *, int32_t, const uint8_t *, int32_t); 00051 extern decDouble * decDoubleFromInt32(decDouble *, int32_t); 00052 extern decDouble * decDoubleFromPacked(decDouble *, int32_t, const uint8_t *); 00053 extern decDouble * decDoubleFromString(decDouble *, const char *, decContext *); 00054 extern decDouble * decDoubleFromUInt32(decDouble *, uint32_t); 00055 extern decDouble * decDoubleFromWider(decDouble *, const decQuad *, decContext *); 00056 extern int32_t decDoubleGetCoefficient(const decDouble *, uint8_t *); 00057 extern int32_t decDoubleGetExponent(const decDouble *); 00058 extern decDouble * decDoubleSetCoefficient(decDouble *, const uint8_t *, int32_t); 00059 extern decDouble * decDoubleSetExponent(decDouble *, decContext *, int32_t); 00060 extern void decDoubleShow(const decDouble *, const char *); 00061 extern int32_t decDoubleToBCD(const decDouble *, int32_t *, uint8_t *); 00062 extern char * decDoubleToEngString(const decDouble *, char *); 00063 extern int32_t decDoubleToInt32(const decDouble *, decContext *, enum rounding); 00064 extern int32_t decDoubleToInt32Exact(const decDouble *, decContext *, enum rounding); 00065 extern int32_t decDoubleToPacked(const decDouble *, int32_t *, uint8_t *); 00066 extern char * decDoubleToString(const decDouble *, char *); 00067 extern uint32_t decDoubleToUInt32(const decDouble *, decContext *, enum rounding); 00068 extern uint32_t decDoubleToUInt32Exact(const decDouble *, decContext *, enum rounding); 00069 extern decQuad * decDoubleToWider(const decDouble *, decQuad *); 00070 extern decDouble * decDoubleZero(decDouble *); 00071 00072 /* Computational (result is a decDouble) */ 00073 extern decDouble * decDoubleAbs(decDouble *, const decDouble *, decContext *); 00074 extern decDouble * decDoubleAdd(decDouble *, const decDouble *, const decDouble *, decContext *); 00075 extern decDouble * decDoubleAnd(decDouble *, const decDouble *, const decDouble *, decContext *); 00076 extern decDouble * decDoubleDivide(decDouble *, const decDouble *, const decDouble *, decContext *); 00077 extern decDouble * decDoubleDivideInteger(decDouble *, const decDouble *, const decDouble *, decContext *); 00078 extern decDouble * decDoubleFMA(decDouble *, const decDouble *, const decDouble *, const decDouble *, decContext *); 00079 extern decDouble * decDoubleInvert(decDouble *, const decDouble *, decContext *); 00080 extern decDouble * decDoubleLogB(decDouble *, const decDouble *, decContext *); 00081 extern decDouble * decDoubleMax(decDouble *, const decDouble *, const decDouble *, decContext *); 00082 extern decDouble * decDoubleMaxMag(decDouble *, const decDouble *, const decDouble *, decContext *); 00083 extern decDouble * decDoubleMin(decDouble *, const decDouble *, const decDouble *, decContext *); 00084 extern decDouble * decDoubleMinMag(decDouble *, const decDouble *, const decDouble *, decContext *); 00085 extern decDouble * decDoubleMinus(decDouble *, const decDouble *, decContext *); 00086 extern decDouble * decDoubleMultiply(decDouble *, const decDouble *, const decDouble *, decContext *); 00087 extern decDouble * decDoubleNextMinus(decDouble *, const decDouble *, decContext *); 00088 extern decDouble * decDoubleNextPlus(decDouble *, const decDouble *, decContext *); 00089 extern decDouble * decDoubleNextToward(decDouble *, const decDouble *, const decDouble *, decContext *); 00090 extern decDouble * decDoubleOr(decDouble *, const decDouble *, const decDouble *, decContext *); 00091 extern decDouble * decDoublePlus(decDouble *, const decDouble *, decContext *); 00092 extern decDouble * decDoubleQuantize(decDouble *, const decDouble *, const decDouble *, decContext *); 00093 extern decDouble * decDoubleReduce(decDouble *, const decDouble *, decContext *); 00094 extern decDouble * decDoubleRemainder(decDouble *, const decDouble *, const decDouble *, decContext *); 00095 extern decDouble * decDoubleRemainderNear(decDouble *, const decDouble *, const decDouble *, decContext *); 00096 extern decDouble * decDoubleRotate(decDouble *, const decDouble *, const decDouble *, decContext *); 00097 extern decDouble * decDoubleScaleB(decDouble *, const decDouble *, const decDouble *, decContext *); 00098 extern decDouble * decDoubleShift(decDouble *, const decDouble *, const decDouble *, decContext *); 00099 extern decDouble * decDoubleSubtract(decDouble *, const decDouble *, const decDouble *, decContext *); 00100 extern decDouble * decDoubleToIntegralValue(decDouble *, const decDouble *, decContext *, enum rounding); 00101 extern decDouble * decDoubleToIntegralExact(decDouble *, const decDouble *, decContext *); 00102 extern decDouble * decDoubleXor(decDouble *, const decDouble *, const decDouble *, decContext *); 00103 00104 /* Comparisons */ 00105 extern decDouble * decDoubleCompare(decDouble *, const decDouble *, const decDouble *, decContext *); 00106 extern decDouble * decDoubleCompareSignal(decDouble *, const decDouble *, const decDouble *, decContext *); 00107 extern decDouble * decDoubleCompareTotal(decDouble *, const decDouble *, const decDouble *); 00108 extern decDouble * decDoubleCompareTotalMag(decDouble *, const decDouble *, const decDouble *); 00109 00110 /* Copies */ 00111 extern decDouble * decDoubleCanonical(decDouble *, const decDouble *); 00112 extern decDouble * decDoubleCopy(decDouble *, const decDouble *); 00113 extern decDouble * decDoubleCopyAbs(decDouble *, const decDouble *); 00114 extern decDouble * decDoubleCopyNegate(decDouble *, const decDouble *); 00115 extern decDouble * decDoubleCopySign(decDouble *, const decDouble *, const decDouble *); 00116 00117 /* Non-computational */ 00118 extern enum decClass decDoubleClass(const decDouble *); 00119 extern const char * decDoubleClassString(const decDouble *); 00120 extern uint32_t decDoubleDigits(const decDouble *); 00121 extern uint32_t decDoubleIsCanonical(const decDouble *); 00122 extern uint32_t decDoubleIsFinite(const decDouble *); 00123 extern uint32_t decDoubleIsInfinite(const decDouble *); 00124 extern uint32_t decDoubleIsInteger(const decDouble *); 00125 extern uint32_t decDoubleIsNaN(const decDouble *); 00126 extern uint32_t decDoubleIsNormal(const decDouble *); 00127 extern uint32_t decDoubleIsSignaling(const decDouble *); 00128 extern uint32_t decDoubleIsSignalling(const decDouble *); 00129 extern uint32_t decDoubleIsSigned(const decDouble *); 00130 extern uint32_t decDoubleIsSubnormal(const decDouble *); 00131 extern uint32_t decDoubleIsZero(const decDouble *); 00132 extern uint32_t decDoubleRadix(const decDouble *); 00133 extern uint32_t decDoubleSameQuantum(const decDouble *, const decDouble *); 00134 extern const char * decDoubleVersion(void); 00135 00136 /* decNumber conversions; these are implemented as macros so as not */ 00137 /* to force a dependency on decimal64 and decNumber in decDouble. */ 00138 #define decDoubleToNumber(dq, dn) decimal64ToNumber((decimal64 *)(dq), dn) 00139 #define decDoubleFromNumber(dq, dn, set) (decDouble *)decimal64FromNumber((decimal64 *)(dq), dn, set) 00140 00141 #endif