"Fossies" - the Fresh Open Source Software Archive 
Member "mapm_4.9.5a/DOCS/struct.ref" (21 Feb 2010, 3670 Bytes) of package /linux/misc/old/mapm-4.9.5a.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
1
2 ============================================================================
3 This file describes the format of the internal representation
4 of an MAPM number in the M_APM data structure
5 M. Ring Nov 10, 2002
6 ============================================================================
7
8 struct M_APM_struct {
9 UCHAR *m_apm_data;
10 long m_apm_id;
11 int m_apm_refcount;
12 int m_apm_malloclength;
13 int m_apm_datalength;
14 int m_apm_exponent;
15 int m_apm_sign;
16 };
17
18
19 The internal representation of the number is in base 100. Each byte in
20 'm_apm_data' can store the values 0-99 (out of a possible 0-255). All
21 numbers mentioned here will be in decimal unless otherwise noted. Base 100
22 was used since that is the largest power of 10 that will fit in one byte.
23 A base that is a power of 10 was chosen since it is real convienent when
24 translating to/from the internal format.
25
26 All math operations will result in a 'normalized' number. In this context,
27 normalized means 2 things; the first nibble of the first byte of data will
28 be non-zero, and all trailing zero's will be ignored. As an example, 25 * 4
29 would normally yield 100, or the digits '1', '0', '0' an have a 'datalength'
30 of 3. Since the trailing zeros carry no information, the datalength will
31 simply be truncated to 1. Note that this assumes the exponent is adjusted
32 accordingly, which we of course do.
33
34 The decimal point of the number is implied to be before the first byte of
35 data. See the examples below.
36
37 'm_apm_data' : An array to hold the digits. The byte at offset 0 will
38 contain the the first 2 (base 10) digits of the number
39 (or 1 base 100 digit), the next byte will contain the
40 3rd and 4th digits, etc. If the number has an odd
41 number of digits, the least significant nibble in the
42 last byte of data will be 0.
43
44 'm_apm_id' : Set during m_apm_init to M_APM_IDENT. Used to
45 validate the structure before the call to 'free'.
46
47 'm_apm_refcount' : NOT used by the basic M_APM. It was added to support
48 the C++ MAPM wrapper class. (However, we do initialize
49 this element to 1).
50
51 'm_apm_malloclength' : Keeps track of how many bytes were allocated in the
52 malloc call to m_apm_data. If a given math operation
53 will yield a result that won't fit into the existing
54 m_apm_data array, we will realloc m_apm_data so it
55 will be guaranteed to hold the result.
56
57 'm_apm_datalength' : The number of base 10 digits in the number. In other
58 words, the number 5678 will have a datalength of 4
59 (which will fit into 2 bytes). The number 1234567 will
60 have a datalength of 7 (which requires 4 bytes to
61 store).
62
63 'm_apm_exponent' : The exponent of the number, can be up to sizeof(int)
64
65 'm_apm_sign' : The sign of the number. sign = -1 is a negative
66 number. sign = +1 is a positive number. sign = 0 is
67 a number that is exactly 0. This feature is used
68 extensively in the library for fast comparisons to 0.
69
70 --------
71 Examples
72 --------
73
74 number sign datalength exponent data: [byte 0,1,2, etc]
75 -----------------------------------------------------------------------
76 0 0 1 0 00
77
78 4.0 +1 1 +1 40 (data = 28h)
79
80 -0.07 -1 1 -1 70 (data = 46h)
81
82 31.6 +1 3 +2 31, 60 (data = 1Fh, 3Ch)
83
84 -52338.226 -1 8 +5 52, 33, 82, 26
85
86 0.0007621 +1 4 -3 76, 21
87
88 3.75900064E+18 +1 9 +19 37, 59, 00, 06, 40
89
90 -6.1289E-7 -1 5 -6 61, 28, 90
91
92 0.872394 +1 6 0 87, 23, 94
93