I have a script that takes the raw numeric tables and truncates the list and estimates the accuracy. It generates a .pm file
When the values are being calculated, fixed point arithmetic will be used.
Here is a bit of the Earth.pm file:
package Earth;
@params_X_exp0_A = (
"A: X: T ^ 0",
"0.99986069925",
"0.02506324281",
"0.00835274807",
"0.00010466796",
"0.00003490608",
"0.00003110838",
"0.00002561408"
);
@params_X_exp0_B = (
"B: X: T ^ 0",
"1.75347045757",
"4.93819429098",
"1.71033525539",
"1.66721984219",
"4.44373803231",
"0.66875189331",
"0.58588607490"
);
@params_X_exp0_C = (
"C: X: T ^ 0",
"6283.31966747490",
"0.24381748350",
"12566.39551746630",
"18849.47136745770",
"6282.83203250789",
"83997.09113559539",
"529.93478257810"
);
Then, a second script converts these numbers into a truncated binary representation. I put the numbers into a little-endian unsigned char array. The different exponents of T are combined into single arrays with the startIndex indicating the boundary between exponents.For example, from above, I get info6.h;
extern const int bytesPerFraction;
extern const int bytesPerInteger[];
extern const unsigned char earth_AHi_X[ ];
extern const unsigned char earth_ALo_X[ ];
extern const unsigned char earth_BHi_X[ ];
extern const unsigned char earth_BLo_X[ ];
extern const unsigned char earth_CHi_X[ ];
extern const unsigned char earth_CLo_X[ ];
extern const int earth_sections_X;
extern const int earth_startIndex_X[1];
extern const int earth_terms_X;
and info6.c/*
6 Digits
BCOUNT (fraction): 3
BCOUNT[A] (integer): 1, max max 1.51664432758
BCOUNT[B] (integer): 1, max max 6.20347631684
BCOUNT[C] (integer): 3, max max 84334.66158130829
Earth:
X_A: T ^ 0: 0.99986069925
X_B: T ^ 0: 4.93819429098
X_C: T ^ 0: 83997.09113559539
...
*/
const int bytesPerFraction = 3; /* 24; 16777216 */
const int bytesPerInteger[] = {
1 /* A: 1.51664432758 */,
1 /* B: 6.20347631684 */,
3 /* C: 84334.66158130829 */
};
const unsigned char earth_AHi_X[ ] = {
0x00 /* 0 0x0 */,
0x00 /* 0 0x0 */,
0x00 /* 0 0x0 */,
0x00 /* 0 0x0 */,
0x00 /* 0 0x0 */,
0x00 /* 0 0x0 */,
0x00 /* 0 0x0 */
};
const unsigned char earth_ALo_X[ ] = {
0xde, 0xf6, 0xff /* 16774878 0xfff6de */,
0x8b, 0x6a, 0x06 /* 420491 0x66a8b */,
0x67, 0x23, 0x02 /* 140135 0x22367 */,
0xdc, 0x06, 0x00 /* 1756 0x6dc */,
0x49, 0x02, 0x00 /* 585 0x249 */,
0x09, 0x02, 0x00 /* 521 0x209 */,
0xad, 0x01, 0x00 /* 429 0x1ad */
};
const unsigned char earth_BHi_X[ ] = {
0x01 /* 1 0x1 */,
0x04 /* 4 0x4 */,
0x01 /* 1 0x1 */,
0x01 /* 1 0x1 */,
0x04 /* 4 0x4 */,
0x00 /* 0 0x0 */,
0x00 /* 0 0x0 */
};
const unsigned char earth_BLo_X[ ] = {
0x70, 0xe3, 0xc0 /* 12641136 0xc0e370 */,
0x80, 0x2d, 0xf0 /* 15740288 0xf02d80 */,
0x88, 0xd8, 0xb5 /* 11917448 0xb5d888 */,
0xeb, 0xce, 0xaa /* 11194091 0xaaceeb */,
0xd0, 0x98, 0x71 /* 7444688 0x7198d0 */,
0x52, 0x33, 0xab /* 11219794 0xab3352 */,
0xa1, 0xfc, 0x95 /* 9829537 0x95fca1 */
};
const unsigned char earth_CHi_X[ ] = {
0x8b, 0x18, 0x00 /* 6283 0x188b */,
0x00, 0x00, 0x00 /* 0 0x0 */,
0x16, 0x31, 0x00 /* 12566 0x3116 */,
0xa1, 0x49, 0x00 /* 18849 0x49a1 */,
0x8a, 0x18, 0x00 /* 6282 0x188a */,
0x1d, 0x48, 0x01 /* 83997 0x1481d */,
0x11, 0x02, 0x00 /* 529 0x211 */
};
const unsigned char earth_CLo_X[ ] = {
0xba, 0xd5, 0x51 /* 5363130 0x51d5ba */,
0xd2, 0x6a, 0x3e /* 4090578 0x3e6ad2 */,
0xa1, 0x40, 0x65 /* 6635681 0x6540a1 */,
0x89, 0xab, 0x78 /* 7908233 0x78ab89 */,
0x15, 0x00, 0xd5 /* 13959189 0xd50015 */,
0xa9, 0x54, 0x17 /* 1529001 0x1754a9 */,
0xe9, 0x4d, 0xef /* 15683049 0xef4de9 */
};
const int earth_sections_X = 1;
const int earth_startIndex_X[1] = {
0
};
const int earth_terms_X = 7;
These were generated with at least 6 decimal digits of fractions.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.