File: decDouble.h

package info (click to toggle)
tarantool 2.6.0-1.4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 85,412 kB
  • sloc: ansic: 513,775; cpp: 69,493; sh: 25,650; python: 19,190; perl: 14,973; makefile: 4,178; yacc: 1,329; sql: 1,074; pascal: 620; ruby: 190; awk: 18; lisp: 7
file content (155 lines) | stat: -rw-r--r-- 10,297 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/* ------------------------------------------------------------------ */
/* decDouble.h -- Decimal 64-bit format module header                 */
/* ------------------------------------------------------------------ */
/* Copyright (c) IBM Corporation, 2000, 2010.  All rights reserved.   */
/*                                                                    */
/* This software is made available under the terms of the             */
/* ICU License -- ICU 1.8.1 and later.                                */
/*                                                                    */
/* The description and User's Guide ("The decNumber C Library") for   */
/* this software is included in the package as decNumber.pdf.  This   */
/* document is also available in HTML, together with specifications,  */
/* testcases, and Web links, on the General Decimal Arithmetic page.  */
/*                                                                    */
/* Please send comments, suggestions, and corrections to the author:  */
/*   mfc@uk.ibm.com                                                   */
/*   Mike Cowlishaw, IBM Fellow                                       */
/*   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         */
/* ------------------------------------------------------------------ */

#if !defined(DECDOUBLE)
  #define DECDOUBLE

  #define DECDOUBLENAME       "decimalDouble"         /* Short name   */
  #define DECDOUBLETITLE      "Decimal 64-bit datum"  /* Verbose name */
  #define DECDOUBLEAUTHOR     "Mike Cowlishaw"        /* Who to blame */

  /* parameters for decDoubles */
  #define DECDOUBLE_Bytes   8      /* length                          */
  #define DECDOUBLE_Pmax    16     /* maximum precision (digits)      */
  #define DECDOUBLE_Emin   -383    /* minimum adjusted exponent       */
  #define DECDOUBLE_Emax    384    /* maximum adjusted exponent       */
  #define DECDOUBLE_EmaxD   3      /* maximum exponent digits         */
  #define DECDOUBLE_Bias    398    /* bias for the exponent           */
  #define DECDOUBLE_String  25     /* maximum string length, +1       */
  #define DECDOUBLE_EconL   8      /* exponent continuation length    */
  #define DECDOUBLE_Declets 5      /* count of declets                */
  /* highest biased exponent (Elimit-1) */
  #define DECDOUBLE_Ehigh (DECDOUBLE_Emax + DECDOUBLE_Bias - (DECDOUBLE_Pmax-1))

  /* Required includes                                                */
  #include "decContext.h"
  #include "decQuad.h"

  /* The decDouble decimal 64-bit type, accessible by all sizes */
  typedef union {
    uint8_t   bytes[DECDOUBLE_Bytes];   /* fields: 1, 5, 8, 50 bits */
    uint16_t shorts[DECDOUBLE_Bytes/2];
    uint32_t  words[DECDOUBLE_Bytes/4];
    #if DECUSE64
    uint64_t  longs[DECDOUBLE_Bytes/8];
    #endif
    } decDouble;

  /* ---------------------------------------------------------------- */
  /* Routines -- implemented as decFloat routines in common files     */
  /* ---------------------------------------------------------------- */

  /* Utilities and conversions, extractors, etc.) */
  extern decDouble * decDoubleFromBCD(decDouble *, int32_t, const uint8_t *, int32_t);
  extern decDouble * decDoubleFromInt32(decDouble *, int32_t);
  extern decDouble * decDoubleFromPacked(decDouble *, int32_t, const uint8_t *);
  extern decDouble * decDoubleFromPackedChecked(decDouble *, int32_t, const uint8_t *);
  extern decDouble * decDoubleFromString(decDouble *, const char *, decContext *);
  extern decDouble * decDoubleFromUInt32(decDouble *, uint32_t);
  extern decDouble * decDoubleFromWider(decDouble *, const decQuad *, decContext *);
  extern int32_t     decDoubleGetCoefficient(const decDouble *, uint8_t *);
  extern int32_t     decDoubleGetExponent(const decDouble *);
  extern decDouble * decDoubleSetCoefficient(decDouble *, const uint8_t *, int32_t);
  extern decDouble * decDoubleSetExponent(decDouble *, decContext *, int32_t);
  extern void        decDoubleShow(const decDouble *, const char *);
  extern int32_t     decDoubleToBCD(const decDouble *, int32_t *, uint8_t *);
  extern char      * decDoubleToEngString(const decDouble *, char *);
  extern int32_t     decDoubleToInt32(const decDouble *, decContext *, enum rounding);
  extern int32_t     decDoubleToInt32Exact(const decDouble *, decContext *, enum rounding);
  extern int32_t     decDoubleToPacked(const decDouble *, int32_t *, uint8_t *);
  extern char      * decDoubleToString(const decDouble *, char *);
  extern uint32_t    decDoubleToUInt32(const decDouble *, decContext *, enum rounding);
  extern uint32_t    decDoubleToUInt32Exact(const decDouble *, decContext *, enum rounding);
  extern decQuad   * decDoubleToWider(const decDouble *, decQuad *);
  extern decDouble * decDoubleZero(decDouble *);

  /* Computational (result is a decDouble) */
  extern decDouble * decDoubleAbs(decDouble *, const decDouble *, decContext *);
  extern decDouble * decDoubleAdd(decDouble *, const decDouble *, const decDouble *, decContext *);
  extern decDouble * decDoubleAnd(decDouble *, const decDouble *, const decDouble *, decContext *);
  extern decDouble * decDoubleDivide(decDouble *, const decDouble *, const decDouble *, decContext *);
  extern decDouble * decDoubleDivideInteger(decDouble *, const decDouble *, const decDouble *, decContext *);
  extern decDouble * decDoubleFMA(decDouble *, const decDouble *, const decDouble *, const decDouble *, decContext *);
  extern decDouble * decDoubleInvert(decDouble *, const decDouble *, decContext *);
  extern decDouble * decDoubleLogB(decDouble *, const decDouble *, decContext *);
  extern decDouble * decDoubleMax(decDouble *, const decDouble *, const decDouble *, decContext *);
  extern decDouble * decDoubleMaxMag(decDouble *, const decDouble *, const decDouble *, decContext *);
  extern decDouble * decDoubleMin(decDouble *, const decDouble *, const decDouble *, decContext *);
  extern decDouble * decDoubleMinMag(decDouble *, const decDouble *, const decDouble *, decContext *);
  extern decDouble * decDoubleMinus(decDouble *, const decDouble *, decContext *);
  extern decDouble * decDoubleMultiply(decDouble *, const decDouble *, const decDouble *, decContext *);
  extern decDouble * decDoubleNextMinus(decDouble *, const decDouble *, decContext *);
  extern decDouble * decDoubleNextPlus(decDouble *, const decDouble *, decContext *);
  extern decDouble * decDoubleNextToward(decDouble *, const decDouble *, const decDouble *, decContext *);
  extern decDouble * decDoubleOr(decDouble *, const decDouble *, const decDouble *, decContext *);
  extern decDouble * decDoublePlus(decDouble *, const decDouble *, decContext *);
  extern decDouble * decDoubleQuantize(decDouble *, const decDouble *, const decDouble *, decContext *);
  extern decDouble * decDoubleReduce(decDouble *, const decDouble *, decContext *);
  extern decDouble * decDoubleRemainder(decDouble *, const decDouble *, const decDouble *, decContext *);
  extern decDouble * decDoubleRemainderNear(decDouble *, const decDouble *, const decDouble *, decContext *);
  extern decDouble * decDoubleRotate(decDouble *, const decDouble *, const decDouble *, decContext *);
  extern decDouble * decDoubleScaleB(decDouble *, const decDouble *, const decDouble *, decContext *);
  extern decDouble * decDoubleShift(decDouble *, const decDouble *, const decDouble *, decContext *);
  extern decDouble * decDoubleSubtract(decDouble *, const decDouble *, const decDouble *, decContext *);
  extern decDouble * decDoubleToIntegralValue(decDouble *, const decDouble *, decContext *, enum rounding);
  extern decDouble * decDoubleToIntegralExact(decDouble *, const decDouble *, decContext *);
  extern decDouble * decDoubleXor(decDouble *, const decDouble *, const decDouble *, decContext *);

  /* Comparisons */
  extern decDouble * decDoubleCompare(decDouble *, const decDouble *, const decDouble *, decContext *);
  extern decDouble * decDoubleCompareSignal(decDouble *, const decDouble *, const decDouble *, decContext *);
  extern decDouble * decDoubleCompareTotal(decDouble *, const decDouble *, const decDouble *);
  extern decDouble * decDoubleCompareTotalMag(decDouble *, const decDouble *, const decDouble *);

  /* Copies */
  extern decDouble * decDoubleCanonical(decDouble *, const decDouble *);
  extern decDouble * decDoubleCopy(decDouble *, const decDouble *);
  extern decDouble * decDoubleCopyAbs(decDouble *, const decDouble *);
  extern decDouble * decDoubleCopyNegate(decDouble *, const decDouble *);
  extern decDouble * decDoubleCopySign(decDouble *, const decDouble *, const decDouble *);

  /* Non-computational */
  extern enum decClass decDoubleClass(const decDouble *);
  extern const char *  decDoubleClassString(const decDouble *);
  extern uint32_t      decDoubleDigits(const decDouble *);
  extern uint32_t      decDoubleIsCanonical(const decDouble *);
  extern uint32_t      decDoubleIsFinite(const decDouble *);
  extern uint32_t      decDoubleIsInfinite(const decDouble *);
  extern uint32_t      decDoubleIsInteger(const decDouble *);
  extern uint32_t      decDoubleIsLogical(const decDouble *);
  extern uint32_t      decDoubleIsNaN(const decDouble *);
  extern uint32_t      decDoubleIsNegative(const decDouble *);
  extern uint32_t      decDoubleIsNormal(const decDouble *);
  extern uint32_t      decDoubleIsPositive(const decDouble *);
  extern uint32_t      decDoubleIsSignaling(const decDouble *);
  extern uint32_t      decDoubleIsSignalling(const decDouble *);
  extern uint32_t      decDoubleIsSigned(const decDouble *);
  extern uint32_t      decDoubleIsSubnormal(const decDouble *);
  extern uint32_t      decDoubleIsZero(const decDouble *);
  extern uint32_t      decDoubleRadix(const decDouble *);
  extern uint32_t      decDoubleSameQuantum(const decDouble *, const decDouble *);
  extern const char *  decDoubleVersion(void);

  /* decNumber conversions; these are implemented as macros so as not  */
  /* to force a dependency on decimal64 and decNumber in decDouble.    */
  /* decDoubleFromNumber returns a decimal64 * to avoid warnings.      */
  #define decDoubleToNumber(dq, dn) decimal64ToNumber((decimal64 *)(dq), dn)
  #define decDoubleFromNumber(dq, dn, set) decimal64FromNumber((decimal64 *)(dq), dn, set)

#endif