root / target-ppc / mfrom_table_gen.c @ 2d72c572
History | View | Annotate | Download (652 Bytes)
1 | 76a66253 | j_mayer | #define _GNU_SOURCE
|
---|---|---|---|
2 | 76a66253 | j_mayer | #include <stdint.h> |
3 | 76a66253 | j_mayer | #include <stdio.h> |
4 | 76a66253 | j_mayer | #include <math.h> |
5 | 76a66253 | j_mayer | |
6 | 76a66253 | j_mayer | int main (void) |
7 | 76a66253 | j_mayer | { |
8 | 76a66253 | j_mayer | double d;
|
9 | 76a66253 | j_mayer | uint8_t n; |
10 | 76a66253 | j_mayer | int i;
|
11 | 3b46e624 | ths | |
12 | 76a66253 | j_mayer | printf("static const uint8_t mfrom_ROM_table[602] =\n{\n ");
|
13 | 76a66253 | j_mayer | for (i = 0; i < 602; i++) { |
14 | 76a66253 | j_mayer | /* Extremly decomposed:
|
15 | 76a66253 | j_mayer | * -T0 / 256
|
16 | 76a66253 | j_mayer | * T0 = 256 * log10(10 + 1.0) + 0.5
|
17 | 76a66253 | j_mayer | */
|
18 | 76a66253 | j_mayer | d = -i; |
19 | 76a66253 | j_mayer | d /= 256.0; |
20 | 76a66253 | j_mayer | d = exp10(d); |
21 | 76a66253 | j_mayer | d += 1.0; |
22 | 76a66253 | j_mayer | d = log10(d); |
23 | 76a66253 | j_mayer | d *= 256;
|
24 | 76a66253 | j_mayer | d += 0.5; |
25 | 76a66253 | j_mayer | n = d; |
26 | 76a66253 | j_mayer | printf("%3d, ", n);
|
27 | 76a66253 | j_mayer | if ((i & 7) == 7) |
28 | 76a66253 | j_mayer | printf("\n ");
|
29 | 76a66253 | j_mayer | } |
30 | 76a66253 | j_mayer | printf("\n};\n");
|
31 | 76a66253 | j_mayer | |
32 | 76a66253 | j_mayer | return 0; |
33 | 76a66253 | j_mayer | } |