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