1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 #if !defined(DECSINGLE)
23 # define DECSINGLE
24
25 # define DECSINGLENAME "decSingle"
26 # define DECSINGLETITLE "Decimal 32-bit datum"
27 # define DECSINGLEAUTHOR "Mike Cowlishaw"
28
29
30 # define DECSINGLE_Bytes 4
31 # define DECSINGLE_Pmax 7
32 # define DECSINGLE_Emin -95
33 # define DECSINGLE_Emax 96
34 # define DECSINGLE_EmaxD 3
35 # define DECSINGLE_Bias 101
36 # define DECSINGLE_String 16
37 # define DECSINGLE_EconL 6
38 # define DECSINGLE_Declets 2
39
40 # define DECSINGLE_Ehigh \
41 (DECSINGLE_Emax + DECSINGLE_Bias - (DECSINGLE_Pmax-1))
42
43
44 # include "decContext.h"
45 # include "decQuad.h"
46 # include "decDouble.h"
47
48
49 typedef union {
50 uint8_t bytes[DECSINGLE_Bytes];
51 uint16_t shorts[DECSINGLE_Bytes/2];
52 uint32_t words[DECSINGLE_Bytes/4];
53 } decSingle;
54
55
56
57
58
59
60 extern decSingle * decSingleFromBCD(decSingle *, int32_t, const uint8_t *, int32_t);
61 extern decSingle * decSingleFromPacked(decSingle *, int32_t, const uint8_t *);
62 extern decSingle * decSingleFromPackedChecked(decSingle *, int32_t, const uint8_t *);
63 extern decSingle * decSingleFromString(decSingle *, const char *, decContext *);
64 extern decSingle * decSingleFromWider(decSingle *, const decDouble *, decContext *);
65 extern int32_t decSingleGetCoefficient(const decSingle *, uint8_t *);
66 extern int32_t decSingleGetExponent(const decSingle *);
67 extern decSingle * decSingleSetCoefficient(decSingle *, const uint8_t *, int32_t);
68 extern decSingle * decSingleSetExponent(decSingle *, decContext *, int32_t);
69 extern void decSingleShow(const decSingle *, const char *);
70 extern int32_t decSingleToBCD(const decSingle *, int32_t *, uint8_t *);
71 extern char * decSingleToEngString(const decSingle *, char *);
72 extern int32_t decSingleToPacked(const decSingle *, int32_t *, uint8_t *);
73 extern char * decSingleToString(const decSingle *, char *);
74 extern decDouble * decSingleToWider(const decSingle *, decDouble *);
75 extern decSingle * decSingleZero(decSingle *);
76
77
78
79
80 extern uint32_t decSingleRadix(const decSingle *);
81 extern const char * decSingleVersion(void);
82
83
84
85
86 # define decSingleToNumber(dq, dn) \
87 decimal32ToNumber((decimal32 *)(dq), dn)
88 # define decSingleFromNumber(dq, dn, set) \
89 decimal32FromNumber((decimal32 *)(dq), dn, set)
90
91 #endif