decSingle.h
This file
Path
vendor/decNumber/decSingle.h
86 lines · 4.8 KiB · C
Last changed by
Not known.
History of this fileTake it
The walk stopped after 200 commits: lines older than fa6a2ff point at it.
website: remove unused root path on building website (#3248)itchynybefore adoptionfa6a2ff
lines 1–86why, one step back1/* ------------------------------------------------------------------ */
2/* decSingle.h -- Decimal 32-bit format module header */
3/* ------------------------------------------------------------------ */
4/* Copyright (c) IBM Corporation, 2000, 2008. All rights reserved. */
5/* */
6/* This software is made available under the terms of the */
7/* ICU License -- ICU 1.8.1 and later. */
8/* */
9/* The description and User's Guide ("The decNumber C Library") for */
10/* this software is included in the package as decNumber.pdf. This */
11/* document is also available in HTML, together with specifications, */
12/* testcases, and Web links, on the General Decimal Arithmetic page. */
13/* */
14/* Please send comments, suggestions, and corrections to the author: */
15/* mfc@uk.ibm.com */
16/* Mike Cowlishaw, IBM Fellow */
17/* IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK */
18/* ------------------------------------------------------------------ */
19
20#if !defined(DECSINGLE)
21 #define DECSINGLE
22
23 #define DECSINGLENAME "decSingle" /* Short name */
24 #define DECSINGLETITLE "Decimal 32-bit datum" /* Verbose name */
25 #define DECSINGLEAUTHOR "Mike Cowlishaw" /* Who to blame */
26
27 /* parameters for decSingles */
28 #define DECSINGLE_Bytes 4 /* length */
29 #define DECSINGLE_Pmax 7 /* maximum precision (digits) */
30 #define DECSINGLE_Emin -95 /* minimum adjusted exponent */
31 #define DECSINGLE_Emax 96 /* maximum adjusted exponent */
32 #define DECSINGLE_EmaxD 3 /* maximum exponent digits */
33 #define DECSINGLE_Bias 101 /* bias for the exponent */
34 #define DECSINGLE_String 16 /* maximum string length, +1 */
35 #define DECSINGLE_EconL 6 /* exponent continuation length */
36 #define DECSINGLE_Declets 2 /* count of declets */
37 /* highest biased exponent (Elimit-1) */
38 #define DECSINGLE_Ehigh (DECSINGLE_Emax + DECSINGLE_Bias - (DECSINGLE_Pmax-1))
39
40 /* Required includes */
41 #include "decContext.h"
42 #include "decQuad.h"
43 #include "decDouble.h"
44
45 /* The decSingle decimal 32-bit type, accessible by all sizes */
46 typedef union {
47 uint8_t bytes[DECSINGLE_Bytes]; /* fields: 1, 5, 6, 20 bits */
48 uint16_t shorts[DECSINGLE_Bytes/2];
49 uint32_t words[DECSINGLE_Bytes/4];
50 } decSingle;
51
52 /* ---------------------------------------------------------------- */
53 /* Routines -- implemented as decFloat routines in common files */
54 /* ---------------------------------------------------------------- */
55
56 /* Utilities (binary argument(s) or result, extractors, etc.) */
57 extern decSingle * decSingleFromBCD(decSingle *, int32_t, const uint8_t *, int32_t);
58 extern decSingle * decSingleFromPacked(decSingle *, int32_t, const uint8_t *);
59 extern decSingle * decSingleFromPackedChecked(decSingle *, int32_t, const uint8_t *);
60 extern decSingle * decSingleFromString(decSingle *, const char *, decContext *);
61 extern decSingle * decSingleFromWider(decSingle *, const decDouble *, decContext *);
62 extern int32_t decSingleGetCoefficient(const decSingle *, uint8_t *);
63 extern int32_t decSingleGetExponent(const decSingle *);
64 extern decSingle * decSingleSetCoefficient(decSingle *, const uint8_t *, int32_t);
65 extern decSingle * decSingleSetExponent(decSingle *, decContext *, int32_t);
66 extern void decSingleShow(const decSingle *, const char *);
67 extern int32_t decSingleToBCD(const decSingle *, int32_t *, uint8_t *);
68 extern char * decSingleToEngString(const decSingle *, char *);
69 extern int32_t decSingleToPacked(const decSingle *, int32_t *, uint8_t *);
70 extern char * decSingleToString(const decSingle *, char *);
71 extern decDouble * decSingleToWider(const decSingle *, decDouble *);
72 extern decSingle * decSingleZero(decSingle *);
73
74 /* (No Arithmetic routines for decSingle) */
75
76 /* Non-computational */
77 extern uint32_t decSingleRadix(const decSingle *);
78 extern const char * decSingleVersion(void);
79
80 /* decNumber conversions; these are implemented as macros so as not */
81 /* to force a dependency on decimal32 and decNumber in decSingle. */
82 /* decSingleFromNumber returns a decimal32 * to avoid warnings. */
83 #define decSingleToNumber(dq, dn) decimal32ToNumber((decimal32 *)(dq), dn)
84 #define decSingleFromNumber(dq, dn, set) decimal32FromNumber((decimal32 *)(dq), dn, set)
85
86#endif